• Advertisement

Archived

This topic is now archived and is closed to further replies.

simple geomenty question...

This topic is 6477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement