#### Archived

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

# points on unit circle

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

## Recommended Posts

Hi, I need to find some points (coordinates) on the unit circle. I need this to determine the direction of a shape (circle for the moment) and yes I really have to do it this way. I have an angle to play with so it shouldn’t be a problem, but it''s. I can''t make it work in the fourth quadrant. If I try to calculate a point at 315 degrees I get a point at (-0,7;0,7) that’s the second quadrant. The strange thing (at least I find it strange) is that I don’t have any problems with points in the third quadrant . Maybe I''m just doing it wrong (or maybe it''s Java playing with me, stupid Java I want my C++) it''s been some years since I''ve done anything like this, and right now I don’t have access to my books or notes. Have I missed something or what? HELP!!!

##### Share on other sites
The x-coordinate should be r*cos(theta) and the y-coordinate should be r*sin(theta) where r is the radius and theta is the angle.

##### Share on other sites
On a unit circle the radius is obviously 1 so a point is simply:

(cos(theta), sin(theta))

##### Share on other sites
Don''t know if this help''s cuz its in C++. I''ve been working on an asteroids clone, so here''s the code to rotate the ship''s facing vector:

void Ship::turn(int direction, float amount)
{
switch(direction)
{
case LEFT:
rotation -= amount;
break;
case RIGHT:
rotation += amount;
break;
}
rotation_radians = (float) rotation * pi/180;

if(rotation > 360) //reset if reached too far.
rotation = rotation - 360;
else if(rotation < 0)
rotation = 360 + rotation;

//think of a unit circle (radius 1)
//The unit vector is the length of the radius
}

Here''s the reason why I was doing that: So I could move the ship forward, in the direction it is facing.

void Ship::move_forward()
{
x += facing.x;
y += facing.y;
}

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 12
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011322
• ### Who's Online (See full list)

There are no registered users currently online

×