Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Green

How do you reverse a normalized normal?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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);

Share this post


Link to post
Share on other sites
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 -- ¦þ
______________________________

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!