simple geomenty question...
Don''t know why I can''t find this info on the web but...
Give the center of a circle (x1,y1) and a source point (x2,y2) on the perimeter of the circle and a degree of separation which we will call (deg) between our source and target (x3,y3) which would also be on the perimitier of the circle - how do we find (x3,y3) if the other points are known.
eg
center of the circle is 0,0
first point or source is 10,10 (which would put it upper right)
the deg of separation would be 22degrees
what is x3,y3?
anyone know of any good basic geometry primers on the net?
I sent a mail to a professor of geometry and he suggested I use complex numbers to achieve my goal.
eg. c1=x1+iy1 etc.
Then rotation by deg units around the origin can be accomplished by multiplying by the complex number (cos deg + i sin deg).
so, to find c3 (Re(c3)=x3 Im(c3)=iy3)
c3=c1+(c2-c1)*(cos deg + i sin deg)
any idea how to implement complex numbers in c and then change them back to real numbers?
eg. c1=x1+iy1 etc.
Then rotation by deg units around the origin can be accomplished by multiplying by the complex number (cos deg + i sin deg).
so, to find c3 (Re(c3)=x3 Im(c3)=iy3)
c3=c1+(c2-c1)*(cos deg + i sin deg)
any idea how to implement complex numbers in c and then change them back to real numbers?
Here''s what to do:
Theta is the angle of choice
alpha = inverse tan((y2-y1)/(x2-x1)) + theta
radius = square root((x2-x1)^2 + (y2-y1)^2)
x3 = cos(alpha) * radius + x1
y3 = sin(alpha) * radius + y1
Theta is the angle of choice
alpha = inverse tan((y2-y1)/(x2-x1)) + theta
radius = square root((x2-x1)^2 + (y2-y1)^2)
x3 = cos(alpha) * radius + x1
y3 = sin(alpha) * radius + y1
Can anyone help me pull this off in c? The only part i cant work out is the inverse tan. do i need a new math lib?
I''m sure that inverse sin/cos/tan is asin/acos/atan
they take the deg. in radians, so you''ll have to convert to radians before using it.
Hope that helps.
they take the deg. in radians, so you''ll have to convert to radians before using it.
Hope that helps.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement