Game Development Community

Math Help

by Matt Ahrens · in Torque Game Engine Advanced · 05/19/2011 (9:57 pm) · 3 replies

I am trying to place six decals in a perfect circle around an object. I have the first decal placed. I need to find the other 5 positions. Each decal should be 60 degrees from the last decal. How do i do this?

#1
05/20/2011 (5:36 am)
There are equations for circles and ovals that you might be able to use, but I'm thinking there might be a simpler solution. If you know your center position then you could just eye-ball it.

Example of 8 points around a (0, 0) center:
1: (-1, 0) --- Left
2: (-1, 1) --- Forward and left
3: (0, 1) --- Forward
4: (1, 1) --- Forward and Right
5: (1, 0) --- Right
6: (1, -1) --- Backward and Right
7: (0, -1) --- Backward
8: (-1,-1) --- Backward and Left

Adding such X and Y values into your center position should give you a nice circle.
#2
05/20/2011 (5:59 am)
i am looking for six points. more like a hexagon, and i think i will need a more sophisticated formula.
#3
05/20/2011 (9:54 am)
The parametric equations of a circle are expressed like this:

for a circle with origin (a, b) and radius r:
x(t) = r cos(t) + a
y(t) = r sin(t) + b
where 0 <= t <= 2PI

in your case t would range over {0, PI/3, 2PI/3, PI, 4PI/3, 5PI/3}

Good Luck!