PDA

View Full Version : Math problem


Jeroen
03-05-2011, 01:18 PM
Hi everyone,

I’m working on a shader and I need some help with a math formula, because I’m stuck.

This is what’s going on, visually.
I’ve got a sphere (sphere B) in my 3D scene parented on a master sphere on coordinates 0 0 0.
The coordinates of Sphere B are X = 8, Y = 6.
When I rotate my master sphere with a angle of 45 degrees (counter clockwise), the new position of sphere B becomes X = 1.414, Y = 4.899.
I’ve got three examples;

1) X = 8 --> X = 1.414
Y = 6 --> Y = 4.899

2) X = 1 --> X = 0
Y = 1 --> Y =1.414

3) X = -2 --> X = 4.243
Y = -8 --> Y = -7.071

I’m looking for a formula that gives me the new position of my sphere B without parenting it to another sphere on 0 0 0 which I rotate 45 degrees.

Gravedigger
03-06-2011, 08:21 AM
not exactly sure what you need but don't rotation matrices work for you?

grs
Patrik

Jeroen
03-06-2011, 09:10 AM
What I mean is, when I have the coordinates X = 8 and Y = 6, I want to know what the new coordinates will be. I took the example of the sphere in 3D space, but it’s for something in the vector output of a shader.

Gravedigger
03-06-2011, 11:13 AM
then simply use a rotation matrix. doesn't that work for you?

grs
Patrik

Jeroen
03-06-2011, 12:35 PM
That sounds good, but where do I find that option/node, how does that work?

ThE_JacO
03-06-2011, 12:40 PM
Are you writing a shader, or are you just plugging nodes together? If the latter, this might not be the best forum for the question, the rendering forums or one specific to the engine you're using would be better suited to a non programming question. The mathematical component of course would be a better fit, but usually telling someone how to plug two nodes together ain't exactly teaching a man to fish :)

That aside, what engine is it you're using and what are you trying to achieve exactly? The question is very vague.

Gravedigger
03-06-2011, 03:11 PM
have a look at this article:
http://en.wikipedia.org/wiki/Rotation_matrix

maybe this clears things up a bit

grs
Patrik

CGTalk Moderation
03-06-2011, 03:11 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.