Figuring an angle?
Das Goravani
goravanis at gmail.com
Sun Oct 10 18:57:14 UTC 2021
I found input on finding an angle online, but I need to figure out how to trap the location of a click in x,y $top $left or just x,y
I figure Omnis probably has a function for that.. will try to figure it out
Otherwise it looks like atan2() is the function that will return a value for this
fun calculateAngle(
touchX: Float,
touchY: Float,
centerX: Float,
centerY: Float
): Float {
val deltaX = centerX - touchX
val deltaY = centerY - touchY
return Math.toDegrees(atan2(deltaY.toDouble(), deltaX.toDouble())).toFloat()
I don’t understand the above, I am not an “other” programmer. But it seems to make sense on face value. I think I can replicate this in Omnis.
> On Oct 10, 2021, at 2:32 PM, Das Goravani <goravanis at gmail.com> wrote:
>
>
> Dear $all,
>
> Can anyone of you figure this out?
>
> I want to know the Angle, in degrees 0 to 360, between two $objs on a thick window.
>
> Picture this, the user drags an object, and when they let go the app figures out the angle between that dragged object and the center of a circle they were dragging over..
>
> Now that I think about it, I think I’m out of luck because although you can drag fields by setting their drag property I don’t think there’s an event when they let go of the field.. and I doubt it’s location properties are set to where it was dragged to.. would have to have fields around the edge they could drag ONTO then we could know the location of what they dropped on.
>
> This is for astrology. I work in circles representing space around the earth. I would love to have drag and get angle so that I could then adjust things onscreen to how they dragged.. they could rotate things..
>
> I think I’m out of luck.
>
> If you have any ideas let me know.
>
> As an alternative, it just occurred to me, that I think there are coordinates available for the location of the mouse pointer.. perhaps they could click a planet they want to drag, and instead of dragging they click the location they want it to go to.. I am given those coordinates by some mouse pointer thing Omnis has, and I work with that.. so given this, it seems I CAN know the location they want to “go to” and I know the center.. so the original question stands, can I know the ANGLE of those two by some trick of math? Does any of you know how to get the angle from two objects or locations onscreen.. in pixels.. I imagine the tan() function might be involved.
>
> I do a lot of work like this kind of thing from another angle of approach.. like typical is I KNOW the angle, and I need to derive the pixels.. I have that wired.. got it from astronomy to computer books.. got a lot from those.. I rotate objects around the screen well.. but I’ve never approached this “selection of an angle” and THEN do something..
>
> It just occurred to me that I could contantly move a line based on location of mouse pointer.. keep one end of the line on the center, move the other end to match the mouse tip, then I’d have an angled line when they let go.. don’t know if that would help me.. but it’s ends are what I want to derive the angle from.
>
> Any of you mathematicians?
>
> Das Goravani
More information about the omnisdev-en
mailing list