12345678910111213141516171819202122232425262728 |
- #include "Plane3D.h"
- #include <iostream>
- using namespace std;
- Plane3D::Plane3D()
- {
- }
- void Plane3D::set(const Vector3D& va, const Vector3D& vb, const Vector3D& vc)
- {
- Vector3D h1 = vb;
- h1.sub(va);
- Vector3D h2 = vc;
- h2.sub(va);
- h1.cross(h2);
- h1.normalize();
-
- a = h1.getX();
- b = h1.getY();
- c = h1.getZ();
- d = -h1.dot(va);
- }
- float Plane3D::getSignedDistance(float x, float y, float z) const
- {
- return x * a + y * b + z * c + d;
- }
|