get a point out of circle.arc
Paul Gr
pauls_postbus at hotmail.com
Sat Jul 29 15:43:24 UTC 2006
hi Felix,
You can use cosinus and sinus functions to compute x and y coordinates of
any point of a circle. In the example below a rectangle with width=100 and
height=50 is drawn at the specified center point (relative to center of
screen).
Dim distance as Double ' pixels
Dim angle as Double ' radians
Dim x as Integer ' center x point of rect
Dim y as Integer ' center y point of rect
Dim w as Integer ' width of rect
Dim h as Integer ' height of rect
dim i as integer
w = 100
h = 50
distance = CDbl(c.getattrib("distance"))
angle = CDbl(c.getattrib("angle")) * 3.14159 / 180
x = Display.XRes/2 + CInt(distance * Cos(angle))
y = Display.YRes/2 + CInt(distance * Sin(angle))
Display.Canvas.Rectangle x-w/2, y-h/2, w, h
Best,
Paul Groot
>From: Felix Fischer <beamgau at gmx.de>
>To: EPRIME at MAIL.TALKBANK.ORG
>Subject: get a point out of circle.arc
>Date: Sat, 29 Jul 2006 14:55:17 +0200
>
>hi everybody,
>
>i want to have rectangles emerging on different positions on the screen.
>their positions should depend on distance from a specific point and angle
>to x-axis.
>
>i can easily reach the points by drawing an arc:
>
>cnvs.Arc XRes/2, YRes/2, c.getattrib("distance"), 0, c.getattrib("angle")
>
>is there a possibility to get the coordinates of the arc's last point?
>later, this should be the middle of the rectangle. or, do you suggest an
>easier way to draw those rectangles, using "distance" and "angle"?
>
>thank you for your help
>felix fischer
>
>
More information about the Eprime
mailing list