# 3D vector rotation

This topic is 2538 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Say, I have an object,i.e apple in my scene.
The light vector is L0. The surface normals of
the object are pointing towards this light,L0.
Now, the light vector moves a bit and becomes
L1. I want to rotate the surface normals of
my object so that it follows the new light,L1.

I computed
->the angle between L0 and L1
->and the axis of rotation

Then I calculated the Rotation matrix R
using angle-axis rotation method. I applied it to
L0 to check whether it results in L0*R=L1
and it works.

Then I applied the same matrix R to surface
normals of my object. But I see its not
working properly.

Is there any bug in my approach? Do I need to
allign my surface normals to any
of the coordinate axis?

##### Share on other sites
What is meant with "the light vector"? The position of a point light source? The direction of a light ray from a light source? Are those vectors given in the same co-ordinate space as the surface normals are?

However, a surface normal is meant to be orthogonal to the surface at a given surface location. Rotating it arbitrarily seems me strange. What is the use case? Perhaps you're speaking of the difference vector from a surface location to a light source position!? Then the way of rotation you're applying will not work at all.

##### Share on other sites

light vector is the difference vector from light position to origin of the coordinate system.
L= (lx,ly,lz)-(0,0,0), where (lx,ly,lz) is the light source position.

I do not mean incident ray here.
So I have 2 such vectors L0 and L1.

I am fixing L0 as (0,0,1) always.
If angle between L0 and L1 is 30 and rotation axis is (0,1,0), then I can
get a rotation matrix R, where L0*R=L1.

I am rotating my surface normals with this R matrix.

What is wrong in my approach? How should I do this?

What is meant with "the light vector"? The position of a point light source? The direction of a light ray from a light source? Are those vectors given in the same co-ordinate space as the surface normals are?

However, a surface normal is meant to be orthogonal to the surface at a given surface location. Rotating it arbitrarily seems me strange. What is the use case? Perhaps you're speaking of the difference vector from a surface location to a light source position!? Then the way of rotation you're applying will not work at all.

• 17
• 10
• 19
• 14
• 19