Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane normalization #42

Open
AlexanderDalshov opened this issue Dec 28, 2016 · 0 comments
Open

Plane normalization #42

AlexanderDalshov opened this issue Dec 28, 2016 · 0 comments

Comments

@AlexanderDalshov
Copy link

Hello,

From my point of view plane normalization contains a bug

Plane is defined with normal and distance.
That means, we should find some plane point just by multiplication:

P = N * D

if plane was defined like:
plane1(Vector3f(0.0f, 2.0f, 0.0f), 3.0f);
means, that P = (0, 6, 0)

after plane normalization with current implementation we will have:
plane1Norm (Vec3(0, 1, 0), 1.5);

as a result P1 = Vec3(0, 1, 0) * 1.5 = (0, 1.5, 0)
instead of (0, 6, 0)

I think in normalized method distance should be multiplied by magnitude instead of division.

Plane Plane::Normalized() const
{
	float magnitude = m_normal.Length();

	//Dividing the normal by it's length performs vector normalization.
	//Distance however, must also be divided by the normal's length in
	//order to create an equivalent plane.
-	return Plane(m_normal/magnitude, m_distance/magnitude);
+	return Plane(m_normal/magnitude, m_distance*magnitude);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant