class Rect3

Represents a rectangle in three dimensional space.

It is represented by two axes that extend from the specified origin. Axes should be perpendicular to each other and they extend in both positive and negative directions from the origin by the amount specified by extents.

Public

Constructors

Rect3

Rect3() = default

Rect3

Rect3(const Vector3 &center, const std::array<Vector3, 2> &axes, const std::array<float, 2> &extents)

Methods

GetNearestPoint

std::pair<std::array<Vector3, 2>, float> GetNearestPoint(const Ray &ray) const

Find the nearest points of the provided ray and the rectangle.

Returns: A set of nearest points and nearest distance. First value in the set corresponds to nearest point on the ray, and the second to the nearest point on the rectangle. They are same in the case of intersection. When ray is parallel to the rectangle there are two sets of nearest points but only one the set nearest to the ray origin is returned.

GetNearestPoint

std::pair<Vector3, float> GetNearestPoint(const Vector3 &point) const

Find the nearest point on the rectangle to the provided point.

Returns: Nearest point and distance to nearest point.

Intersects

std::pair<bool, float> Intersects(const Ray &ray) const

Ray/rectangle intersection.

Returns: Boolean result and distance to intersection point.

Fields

Center

Vector3 Center

HorizontalAxis

Vector3 HorizontalAxis

VerticalAxis

Vector3 VerticalAxis

HorizontalExtent

float HorizontalExtent

VerticalExtent

float VerticalExtent