## 3D circle movement

Moderator
Posts: 133
Joined: 2008.05
Post: #1
It's probably a simple math question, been awhile since I've done any kind of real trig though.

I want to create circular paths, basically. I achieve this on the xy axis by finding the position of a particle with radius * cos(x) and radius * sin(y). Well, actually, cos(y + 90), so I can use vcosf. That's fine and dandy. As is my yz, because they are opposite trig functions. However, xz just creates a straight line, since I'm using the same trig function. I'd just switch the trig function on Z, but then if I had x, y and z movement, the YZ wouldn't create a circle. Should I be using tangent(even though it's undefined at certain points), or is there another way around this?
Sage
Posts: 1,487
Joined: 2002.09
Post: #2

Could you clarify what exactly you are trying to accomplish.
Moderator
Posts: 133
Joined: 2008.05
Post: #3
Okay, say you have a circle with radius = 1.

If you want to traverse around the circle, you'd just set your positions up with trig functions and the angle you are on the circle. So x = cos(rotation), y = sin(rotation). That'd make a circle, so if you had some dot with positions at {cos®, sin®}, as you increase r, the dot moves in a circular direction... basically, circling the z axis.

When you add in a third dimension, if you use cos® to find z, you will create a circular movement around the x axis, if you use sin® to find z, you will create a circular movement around the y axis. Unfortunately, you can't do both. I'm asking what trig function I will need to put my angle through in order to obtain a z coordinate that makes the dot move in a sphere like pattern.
Moderator
Posts: 776
Joined: 2003.04
Post: #4
"sphere like pattern"?
Member
Posts: 184
Joined: 2004.07
Post: #5
If you have created a point motion around a certain axis, you could apply a rotation matrix to the position of the point to change the axis of rotation.

Another way that would be easy to "cheat" if you want a nice orbit is to use the same movement laws as gravitation- if your particle has some velocity and is accelerating towards the center of the sphere, you will get an orbit. If you want it to be perfect you could make it so that the particle always lies on the sphere and the velocity is always of constant length.
Sage
Posts: 1,403
Joined: 2005.07
Post: #6
Well theres about infinity sphere like patterns but heres a nice spirally one
Just try different things until you get one you like
0 < t < 1
[sin(2Ï€ t), cos(2Ï€ t), 2t-1]

Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
Moderator
Posts: 1,563
Joined: 2003.10
Post: #7
I suspect this is what you'll want.

http://www.sacredsoftware.net/tutorials/...ions.xhtml

- Alex Diener