86 lines
3.3 KiB
C++
86 lines
3.3 KiB
C++
#pragma once
|
|
#include <J3ML/LinearAlgebra/Vector3.h>
|
|
#include "Shape.h"
|
|
#include "Ray.h"
|
|
|
|
|
|
namespace J3ML::Geometry
|
|
{
|
|
using J3ML::LinearAlgebra::Vector3;
|
|
|
|
class Plane : public Shape
|
|
{
|
|
public:
|
|
Vector3 Position;
|
|
Vector3 Normal;
|
|
float distance = 0.f;
|
|
public:
|
|
Plane() : Shape() {}
|
|
Plane(const Vector3& v1, const Vector3 &v2, const Vector3& v3);
|
|
Plane(const Vector3& pos, const Vector3& norm);
|
|
Plane(const Line &line, const Vector3 &normal);
|
|
|
|
void Set(const Vector3& v1, const Vector3& v2, const Vector3& v3);
|
|
|
|
void Set(const Vector3 &point, const Vector3 &normal_);
|
|
|
|
bool Intersects(J3ML::Geometry::Ray ray, float *dist) const;
|
|
|
|
/// Tests if the given point lies on the positive side of this plane.
|
|
/** A plane divides the space in three sets: the negative halfspace, the plane itself, and the positive halfspace.
|
|
The normal vector of the plane points towards the positive halfspace.
|
|
@return This function returns true if the given point lies either on this plane itself, or in the positive
|
|
halfspace of this plane.
|
|
@see IsInPositiveDirection, AreOnSameSide(), Distance(), SignedDistance(). */
|
|
bool IsOnPositiveSide(const Vector3 &point) const;
|
|
|
|
float SignedDistance(const Vector3 &point) const;
|
|
float SignedDistance(const AABB &aabb) const;
|
|
float SignedDistance(const OBB &obb) const;
|
|
float SignedDistance(const Capsule &capsule) const;
|
|
//float Plane::SignedDistance(const Circle &circle) const { return Plane_SignedDistance(*this, circle); }
|
|
float SignedDistance(const Frustum &frustum) const;
|
|
//float SignedDistance(const Line &line) const { return Plane_SignedDistance(*this, line); }
|
|
float SignedDistance(const LineSegment &lineSegment) const;
|
|
float SignedDistance(const Ray &ray) const;
|
|
//float Plane::SignedDistance(const Plane &plane) const { return Plane_SignedDistance(*this, plane); }
|
|
float SignedDistance(const Polygon &polygon) const;
|
|
float SignedDistance(const Polyhedron &polyhedron) const;
|
|
float SignedDistance(const Sphere &sphere) const;
|
|
float SignedDistance(const Triangle &triangle) const;
|
|
|
|
static bool
|
|
IntersectLinePlane(const Vector3 &planeNormal, float planeD, const Vector3 &linePos, const Vector3 &lineDir,
|
|
float &t);
|
|
|
|
float Distance(const Vector3 &) const;
|
|
|
|
float Distance(const LineSegment &lineSegment) const;
|
|
|
|
float Distance(const Sphere &sphere) const;
|
|
|
|
float Distance(const Capsule &capsule) const;
|
|
|
|
bool Intersects(const Line &line, float *dist) const;
|
|
|
|
bool Intersects(const LineSegment &lineSegment, float *dist) const;
|
|
|
|
bool Intersects(const Sphere &sphere) const;
|
|
|
|
bool Intersects(const Capsule &capsule) const;
|
|
|
|
bool Intersects(const AABB &aabb) const;
|
|
|
|
bool Intersects(const OBB &obb) const;
|
|
|
|
bool Intersects(const Triangle &triangle) const;
|
|
|
|
bool Intersects(const Frustum &frustum) const;
|
|
|
|
bool Intersects(const Polyhedron &polyhedron) const;
|
|
|
|
LineSegment Project(const LineSegment &segment);
|
|
|
|
Vector3 Project(const Vector3 &point) const;
|
|
};
|
|
} |