bool Plane::Intersects(const Ray &ray, float *d) const { float t; bool success = IntersectLinePlane(PointOnPlane(), normal, ray.pos, ray.dir, &t); if (d) *d = t; return success && t >= 0.f; }
bool Plane::Intersects(const LineSegment &lineSegment, float *d) const { float t; bool success = IntersectLinePlane(PointOnPlane(), normal, lineSegment.a, lineSegment.Dir(), &t); const float lineSegmentLength = lineSegment.Length(); if (d) *d = t / lineSegmentLength; return success && t >= 0.f && t <= lineSegmentLength; }
bool Plane::Intersects(const Line &line, float *d) const { return IntersectLinePlane(PointOnPlane(), normal, line.pos, line.dir, d); }
vec Plane::Point(float u, float v) const { vec b1, b2; normal.PerpendicularBasis(b1, b2); return PointOnPlane() + u * b1 + v * b2; }
vec Plane::Point(float u, float v) const { return PointOnPlane() + u * normal.Perpendicular() + v * normal.AnotherPerpendicular(); }