How do you reverse a normalized normal?

Started by
5 comments, last by Green 21 years, 7 months ago
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]
Advertisement
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", A third book on advanced lighting and materials
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
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);
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 -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
Wow,

that explains why this entire week of working on collision detection and frustum culling was so difficult. I was getting positive numbers even though my normal''s direction was negative!

Doh!

Thanks for stopping the horror.

Lifes pretty funny when your a newb!
the inverse of Vector V is simply -V

maybe this need an operator.

This topic is closed to new replies.

Advertisement