Math problem


#1

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.


#2

not exactly sure what you need but don’t rotation matrices work for you?

grs
Patrik


#3

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.


#4

then simply use a rotation matrix. doesn’t that work for you?

grs
Patrik


#5

That sounds good, but where do I find that option/node, how does that work?


#6

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 :slight_smile:

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


#7

have a look at this article:
http://en.wikipedia.org/wiki/Rotation_matrix

maybe this clears things up a bit

grs
Patrik


#8

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.