Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trig Calculation....
Message
From
18/12/2003 08:52:53
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00859407
Message ID:
00860306
Views:
24
Hi Viv,

Yes, I oversimplified.

Seems OK to me. Haven't gone through the logic since you say it works all right.

There's an event each time the arc passes/encounters an axis ( at 0, at 90, at 180 or at 270 degrees). Top|Bottom|Left|Right of the rectangle have to be adjusted then.

Which is what you are doing ..


>Hi Gregory,
>
>>>
>If I have understood correctly ..
>Given
>angle (a) starting at (0,0) 0 degrees moving counterclockwise ( if the center of the circle does not start at (0,0) or the angle does not start at 0 degrees, you'll have to move/rotate the origin of the outcome below; forgot the formula, but should be easy to find)
>>>
>
>The centre of the circle is at 0,0 ; zero degree angle is +x,0, angle increasing counterclockwise but the arc is defined in a clockwise direction. My problem is really with the second bit - the start angle can be any value and I think the initial calculation has to reflect that. I can easily calculate the xy coordinates of the start and end points of the arc ; it's calculating the rectangles size and offset from the centre point that's annoying me. My (VB pseudo-)code at the moment is something like:
>
>RectLeft = Min(StartX, EndX)
>RectRight = Max(StartX, EndX)
>RectTop = Min(Starty, Endy)
>RectBottom = Max(Starty, Endy)
>
>' Adjust for maxed quadrants
>ArcEnd = StartAngle - ArcAngle
>If ArcEnd > 0 Then
>  ' Doesn't cross 0 Radian
>  If ArcEnd < 90 Then RectTop = -Radius
>  If ArcEnd < 180 Then RectLeft = -Radius
>  If ArcEnd < 270 Then RectBottom = Radius
>Else
>  ' Crosses 0
>  RectRight = Radius
>  If ArcEnd < -90 Or StartAngle > 270 Then RectBottom = Radius
>  If ArcEnd < -180 Or StartAngle > 180 Then RectLeft = -Radius
>  If ArcEnd < -270 Or StartAngle > 90 Then RectTop = -Radius
>End If
>
>
>It works OK - just looks ugly to me. Or maybe I should be trying something else entirely...
>
>Regards,
>Viv
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform