| 08-07-2009, 10:25 PM | #1 |
Basically I need to rotate points on a sphere around an arbitrary axis. The axis passes through the center of the sphere and is parallel with what might be considered the ground. The arbitrary axis itself is determined by a rotation around the z axis. If anything isn't clear please tell me and I'll try to clarify. This problem has been driving me nuts and any help is appreciated. |
| 08-07-2009, 10:33 PM | #2 |
Can you make a visual aid lol? I can't visualize what you're saying. Perhaps this would help? |
| 08-07-2009, 10:40 PM | #3 |
Ok I stole the picture off of some random website, so ignore the variables and the triangle, they're unrelated.. Notice the y axis. Now pretend I rotated that y axis along the z axis. Lets say I rotate it 45 degrees. Now I'd have an arbitrary axis between the x and y axis, but along the same plane. How would I go about rotating the whole sphere around that axis? (By whole sphere, I mean a finite amount of points that we're previously calculated to make up the sphere) Another note, 45 degrees was for the example, really I need an equation that'll work with any angle. |
| 08-07-2009, 10:49 PM | #4 |
Man that's hard, I'm sorry can't help you with the maths of that lol, hopefully someone here like rising_dusk, anitarf or pyrogasm could. |
| 08-07-2009, 11:20 PM | #5 |
Just use spherical to cartesian coordinate transformations: Code:
x = rcos(θ)sin(φ) y = rsin(θ)sin(φ) z = rcos(φ) Reference: http://mathworld.wolfram.com/SphericalCoordinates.html |
| 08-07-2009, 11:34 PM | #6 |
Sorry, I'm going to need an example. I really don't understand =S Keep in mind that my objective is rotating prexisting points (that make a sphere) along the arbitrary axis specified in my other posts. |
| 08-08-2009, 12:06 AM | #7 |
All Dusk did was transform from cartesian (ie x, y, z) coordinate system to a sphereical one. You can do the same thing in reverse too. Basically, it transforms it to work on a sphereical plane with a constant radius r. All you do is control 2 angles, theta and phi, and that'll give you any point along the surface of the sphere. From there you can do all sorts of things. For example, if you want something so oribit it randomly, set a delta_theta and delta_phi to 2 random values and if you want an even stranger orbit, randomize them and give them acceleration values too. If you want to rotate at a certian angle, then fix one of the angles constant and work around that. |
| 08-08-2009, 12:10 AM | #8 |
I think I might have a shadow of an understanding. I'm going to go mess around with it, and see if I can come to a full understanding. |
| 08-08-2009, 12:19 AM | #9 |
Just for clarification, does rotating a dummy unit around a unit translate to "rotating about the z axis", wherein the z offset remains constant? |
| 08-08-2009, 12:22 AM | #10 | ||
Quote:
Quote:
|
| 08-08-2009, 12:26 AM | #11 |
How about this, is that what you are looking for? |
| 08-08-2009, 12:44 AM | #12 |
I googled before posting this and found that. It's not what I need because it uses a line segment to define it's axis. The axis I'm using has some factors specified in my previous posts that greatly simplify what I need to do. That method is much more complicated then what I need. Thanks for trying though! Ok, I think it's time to get really really explicit. Open the attached map and run it. After a few seconds a sphere should appear. That sphere is built using Rising_Dusk's suggestion. Ten seconds after that the sphere should change. It should begin tilting to the left. At first it looks like it's working, then the shape melts down into something crazy proving I did not succeed with my other method. Basically I want to change the sphere using a facingangle to set where the sphere is facing. and a turnangle to set how much it's turned in that direction. Any help is appreciated |
| 08-08-2009, 01:55 AM | #13 |
VectorLib comes with a method that rotates a set of coordinates around any axis. |
| 08-08-2009, 01:58 AM | #14 | |
Quote:
|
| 08-08-2009, 03:36 AM | #15 | ||
Quote:
Quote:
However that does not help my problem! Please re-read my question, or better yet look at the above quoted post. If anything needs to be clarified you can tell me that too. Or if it does indeed solve my problem, I would really like an example, as I am obviously still not understanding it. It's time to get super explicit... Ok imagine you have a sphere. Now imagine a diameter line in the sphere. Goes from one edge to the other edge of the sphere and passes through the center. Now imagine that you want to rotate the whole sphere 30 degrees along the direction the diameter is pointing. To recalculate the new lines (as there is one line each starting at the center and going outward that makes up the diameter) we can simply change the values in the equation. This would be the diameter. The line would be created by going from 0,0,0 to xyz x = 10cos(0)sin(90) y = 10sin(0)sin(90) z = 10cos(90) and the second part of the diameter x = 10cos(180)sin(90) y = 10sin(180)sin(90) z = 10cos(90) Now we rotate the sphere 'forward' 30 degrees This would be the diameter. The line would be created by going from 0,0,0 to xyz x = 10cos(0)sin(90-30) y = 10sin(0)sin(90-30) z = 10cos(90) and the second part of the diameter x = 10cos(180)sin(90+30) y = 10sin(180)sin(90+30) z = 10cos(90) Finally, we come to the problem. Lets pretend there is a third line segment part of the sphere x = 10cos(45)sin(90) y = 10sin(45)sin(90) z = 10cos(90) Now the sphere rotates 30 degrees in the direction it rotated with the diameter x = 10cos(45)sin(90-30) y = 10sin(45)sin(90-30) z = 10cos(90) The above WELL NOT WORK!!!! Because the line is at an angle to the sphere's rotation we CANT add 30. Instead we need to add a % of 30... or something like that. THIS IS THE PART I NEED HELP ON If you don't believe me, go ahead and try it. I hope I made it clear, I really did try. |
