How do you reverse a normalized normal?
I dont really know what I'm talking about but...
I have a planes normal:
normal.x = 0
normal.y = 0
normal.z = 1
but I want it to point in the opposite direction. I am under the impression that a normalized normal = 1 so I cannot simply do this:
normal.x = 0
normal.y = 0
normal.z = -1
What must I do?
[edited by - Green on September 15, 2002 7:53:11 PM]
normalized means that the *magnitude* equals 1. Negativity is a component of the direction. So.... (0, 0, -1) is normalized.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"
reversing a vector is just changing all the signs..there''s no problem with that. The length stays at 1.
Runicsoft -- home of my open source Function Parser and more
Runicsoft -- home of my open source Function Parser and more
How come I get the same positive result in both these cases, when my ray and ray vector are the same:
Case 1:
normal[2].x = 0;
normal[2].y = 0;
normal[2].z = 1;
Case 2:
normal[2].x = 0;
normal[2].y = 0;
normal[2].z = -1;
Given formula:
d = D3DXVec3Dot(&normal, &point);
numer = D3DXVec3Dot(&normal, &ray) - d;
denom = D3DXVec3Dot(&normal, &rayVector);
Distance = -(numer / denom);
Case 1:
normal[2].x = 0;
normal[2].y = 0;
normal[2].z = 1;
Case 2:
normal[2].x = 0;
normal[2].y = 0;
normal[2].z = -1;
Given formula:
d = D3DXVec3Dot(&normal, &point);
numer = D3DXVec3Dot(&normal, &ray) - d;
denom = D3DXVec3Dot(&normal, &rayVector);
Distance = -(numer / denom);
length of vector = sqrt(x2+y2+z2)
Notice that the answer is always positive (assuming real numbers but come on...) regardless of the sign of the components. Whenever you square a real number you get a positive number. By the way, to reverse any direction vector, just scale it (multiply all of its components) by -1.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
Notice that the answer is always positive (assuming real numbers but come on...) regardless of the sign of the components. Whenever you square a real number you get a positive number. By the way, to reverse any direction vector, just scale it (multiply all of its components) by -1.
_____________________________
And the Phoenix shall rise from the ashes...
--Thunder_Hawk -- ¦þ
______________________________
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement