Figuring an angle?

Doug Easterbrook doug at artsman.com
Sun Oct 10 19:17:00 UTC 2021


you can drag any foreground or background object on a window if you set the drag properties to allow dragging.   $dragmode. set to drag object

you can limit how far you want it dragged:   $dragrange .   you probably want to limit to the window


in the object you are dragging. you can check for $events

there is one for evDragFinished



when the drag is finished, you can get the $height,$width,$top,$left and use those to calculate the centre of the object


and then its math to calculate the angle using two vectors
https://onlinemschool.com/math/library/vector/angl/

I suggest vectors since I don’t know what the central point is .. but if the central point i.e. (0,0)  is considered the same, you might be able to reduce to this answer in stack overflow https://stackoverflow.com/questions/2676719/calculating-the-angle-between-the-line-defined-by-two-points

there is an example in the middle of the stack overflow answer that might indicate if it satisfies what you are trying to do.






Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978

> On October 10, 2021, at 11:32 AM, 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
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com



More information about the omnisdev-en mailing list