137 float v2lX = x -
p1X;
138 float v2lY = y -
p1Y;
143 if (v < 0.0f || w < 0.0f || v > 1.0f || w > 1.0f)
return false;
168 float p0 = axes[0].
X * (
p1X - c.
X) + axes[0].Y * (
p1Y - c.
Y);
169 float p2 = axes[0].
X * (
p3X - c.
X) + axes[0].Y * (
p3Y - c.
Y);
171 float r = e.
X * fabsf(axes[0].X) + e.
Y * fabsf(axes[0].Y);
176 p0 = axes[1].
X * (
p1X - c.
X) + axes[1].Y * (
p1Y - c.
Y);
177 float p1 = axes[1].
X * (
p2X - c.
X) + axes[1].Y * (
p2Y - c.
Y);
179 r = e.
X * fabsf(axes[1].X) + e.
Y * fabsf(axes[1].Y);
184 p0 = axes[2].
X * (
p1X - c.
X) + axes[2].Y * (
p1Y - c.
Y);
185 p1 = axes[2].
X * (
p2X - c.
X) + axes[2].Y * (
p2Y - c.
Y);
187 r = e.
X * fabsf(axes[2].X) + e.
Y * fabsf(axes[2].Y);
Defines the Triangle2D class for representing and manipulating 2D triangles.
Represents a 2D axis-aligned bounding box.
bool Overlaps(BoundingBox2D *bb)
Checks if this bounding box overlaps with another BoundingBox2D.
Vector2D GetMinimum()
Gets the minimum corner of the bounding box.
Vector2D GetMaximum()
Gets the maximum corner of the bounding box.
Abstract base class for rendering materials.
static T Min(T value1, T value2)
Returns the minimum of two values.
static T Max(T value1, T value2)
Returns the maximum of two values.
A mathematical construct representing a rotation in 3D space.
Vector2D UnrotateVector(const Vector2D &coordinate) const
Applies the inverse of this quaternion's rotation to a 2D vector.
Quaternion Multiply(const Quaternion &quaternion) const
Multiplies (composes) this quaternion with another (order matters).
String ToString()
Converts the triangle's data to a string representation.
bool DidIntersectSAT(BoundingBox2D *bbox)
Checks if the triangle intersects a bounding box using the Separating Axis Theorem (SAT).
Vector3D * normal
Normal vector of the triangle (if available).
Material * GetMaterial()
Gets the material assigned to the triangle.
const Vector2D * p2UV
UV coordinates of the second vertex.
Vector2D GetP2()
Gets the second vertex as a 2D point.
Vector3D * t3p1
Pointer to the first vertex in 3D space.
Triangle2D()
Default constructor.
Vector2D max
Minimum and maximum bounds of the triangle.
bool hasUV
Indicates whether the triangle has UV mapping.
bool DidIntersect(const float &x, const float &y, float &u, float &v, float &w)
Checks if a point intersects the triangle using barycentric coordinates.
float averageDepth
Average depth of the triangle for rendering.
float denominator
Precomputed denominator for barycentric coordinate calculations.
Vector3D * t3p3
Pointer to the third vertex in 3D space.
Vector2D GetP1()
Gets the first vertex as a 2D point.
const Vector2D * p3UV
UV coordinates of the third vertex.
Vector2D GetP3()
Gets the third vertex as a 2D point.
Vector3D * t3p2
Pointer to the second vertex in 3D space.
const Vector2D * p1UV
UV coordinates of the first vertex.
Material * material
Material assigned to the triangle.
float p3Y
Coordinates of the triangle's vertices.
Represents a 3D triangle with support for UV mapping and ray intersection testing.
const Vector2D * p2UV
Pointer to the UV coordinates of the second vertex.
Vector3D * p1
Pointer to the first vertex of the triangle.
Vector3D * Normal()
Calculates and returns the normal of the triangle.
Vector3D * p3
Pointer to the third vertex of the triangle.
bool hasUV
Indicates whether the triangle has UV mapping.
Vector3D * p2
Pointer to the second vertex of the triangle.
const Vector2D * p3UV
Pointer to the UV coordinates of the third vertex.
const Vector2D * p1UV
Pointer to the UV coordinates of the first vertex.
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
String ToString() const
Converts the vector to a string representation.
float X
The X-component of the 2D vector.
float Y
The Y-component of the 2D vector.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
float Z
The Z-component of the 3D vector.
float X
The X-component of the 3D vector.
float Y
The Y-component of the 3D vector.