Implement Circle header, rename all files to use .hpp extension.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
// Transcribed from here: explicit form and derivative
|
||||
// https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B%C3%A9zier_curves
|
||||
|
||||
#include "J3ML/LinearAlgebra/Vector2.h"
|
||||
#include "J3ML/LinearAlgebra/Vector2.hpp"
|
||||
|
||||
namespace J3ML::Algorithm
|
||||
{
|
||||
|
@@ -3,8 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/Geometry.h>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <J3ML/Geometry.hpp>
|
||||
|
||||
namespace J3ML::Algorithms
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "J3ML/J3ML.h"
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
namespace J3ML::Algorithm
|
||||
{
|
||||
|
@@ -1,26 +0,0 @@
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/Geometry/AABB2D.hpp>
|
||||
#include <J3ML/Geometry/Plane.h>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/Line.h>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include <J3ML/Geometry/Frustum.h>
|
||||
#include <J3ML/Geometry/OBB.h>
|
||||
#include <J3ML/Geometry/Capsule.h>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Polyhedron.h>
|
||||
#include <J3ML/Geometry/QuadTree.h>
|
||||
#include <J3ML/Geometry/Ray.h>
|
||||
#include <J3ML/Geometry/Shape.h>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/Triangle.h>
|
||||
#include <J3ML/Geometry/Triangle2D.h>
|
||||
#include <J3ML/Geometry/TriangleMesh.h>
|
||||
#include <J3ML/Geometry/PBVolume.hpp>
|
||||
|
||||
#include <J3ML/Geometry/KDTree.h>
|
||||
|
||||
using namespace J3ML::Geometry;
|
26
include/J3ML/Geometry.hpp
Normal file
26
include/J3ML/Geometry.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/Geometry/AABB2D.hpp>
|
||||
#include <J3ML/Geometry/Plane.hpp>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
#include <J3ML/Geometry/Line.hpp>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include <J3ML/Geometry/Frustum.hpp>
|
||||
#include <J3ML/Geometry/OBB.hpp>
|
||||
#include <J3ML/Geometry/Capsule.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Polyhedron.hpp>
|
||||
#include <J3ML/Geometry/QuadTree.hpp>
|
||||
#include <J3ML/Geometry/Ray.hpp>
|
||||
#include <J3ML/Geometry/Shape.hpp>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
#include <J3ML/Geometry/Triangle.hpp>
|
||||
#include <J3ML/Geometry/Triangle2D.hpp>
|
||||
#include <J3ML/Geometry/TriangleMesh.hpp>
|
||||
#include <J3ML/Geometry/PBVolume.hpp>
|
||||
|
||||
#include <J3ML/Geometry/KDTree.hpp>
|
||||
|
||||
using namespace J3ML::Geometry;
|
@@ -3,12 +3,12 @@
|
||||
#include <format>
|
||||
#include <optional>
|
||||
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Shape.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <J3ML/Geometry/Shape.hpp>
|
||||
|
||||
#include "Polygon.h"
|
||||
#include "Sphere.h"
|
||||
#include "Polygon.hpp"
|
||||
#include "Sphere.hpp"
|
||||
#include <J3ML/Algorithm/RNG.hpp>
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include "Shape.h"
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
#include "Shape.hpp"
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
@@ -45,7 +45,6 @@ namespace J3ML::Geometry
|
||||
|
||||
Vector2 ToNormalizedLocalSpace(const Vector2 &pt) const;
|
||||
|
||||
|
||||
AABB2D operator+(const Vector2& pt) const;
|
||||
|
||||
AABB2D operator-(const Vector2& pt) const;
|
||||
|
@@ -1,21 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Shape.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <J3ML/Geometry/Shape.hpp>
|
||||
#include "Circle.hpp"
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
|
||||
|
||||
/// A 3D cylinder with spherical ends.
|
||||
class Capsule : public Shape
|
||||
{
|
||||
public:
|
||||
// Specifies the two inner points of this capsule
|
||||
/// Specifies the two inner points of this capsule
|
||||
LineSegment l;
|
||||
// Specifies the radius of this capsule
|
||||
/// Specifies the radius of this capsule
|
||||
float r;
|
||||
public:
|
||||
/// The default constructor does not initialize any members of this class.
|
||||
@@ -34,8 +34,17 @@ namespace J3ML::Geometry
|
||||
@see l, r. */
|
||||
Capsule(const Vector3& bottomPt, const Vector3& topPt, float radius);
|
||||
|
||||
/// Constructs a new capsule from a sphere.
|
||||
/** This conversion results in a capsule which has its both endpoints at the exact same coordinates, and hence the
|
||||
length of the inner line segment is set to 0. */
|
||||
void SetFrom(const Sphere& s);
|
||||
|
||||
/// Sets this Capsule to a degenerate negative-volume state.
|
||||
void SetDegenerate();
|
||||
|
||||
|
||||
/// Quickly returns an arbitrary point inside this Capsule. Used in GJK intersection test.
|
||||
inline Vector3 AnyPointFast() const { return l.A; }
|
||||
[[nodiscard]] inline Vector3 AnyPointFast() const;
|
||||
|
||||
/// Generates a point that perhaps lies inside this capsule.
|
||||
/** @param height A normalized value between [0,1]. This specifies the point position along the height line of this capsule.
|
||||
@@ -46,10 +55,10 @@ namespace J3ML::Geometry
|
||||
Vector3 UniformPointPerhapsInside(float height, float x, float y) const;
|
||||
|
||||
/// Returns the Sphere defining the 'bottom' section of this Capsule (corresponding to the endpoint l.a)
|
||||
Sphere SphereA() const;
|
||||
[[nodiscard]] Sphere SphereA() const;
|
||||
|
||||
/// Returns the Sphere defining the 'top' section of this Capsule (corresponding to the endpoint l.b)
|
||||
Sphere SphereB() const;
|
||||
[[nodiscard]] Sphere SphereB() const;
|
||||
|
||||
/// Computes the extreme point of this Capsule in the given direction.
|
||||
/** An extreme point is a farthest point of this Capsule in the given direction. Given a direction,
|
||||
@@ -57,22 +66,22 @@ namespace J3ML::Geometry
|
||||
@param direction The direction vector of the direction to find the extreme point. This vector may
|
||||
be unnormalized, but may not be null.
|
||||
@return The extreme point of this Capsule in the given direction. */
|
||||
Vector3 ExtremePoint(const Vector3 &direction) const;
|
||||
[[nodiscard]] Vector3 ExtremePoint(const Vector3 &direction) const;
|
||||
Vector3 ExtremePoint(const Vector3 &direction, float &projectionDistance) const;
|
||||
|
||||
/// Tests if this Capsule is degenerate.
|
||||
/** @return True if this Capsule does not span a strictly positive volume. */
|
||||
bool IsDegenerate() const;
|
||||
[[nodiscard]] bool IsDegenerate() const;
|
||||
|
||||
/// Computes the total height of this capsule, i.e. LineLength() + Diameter().
|
||||
/** <img src="CapsuleFunctions.png" />
|
||||
@see LineLength(). */
|
||||
float Height() const;
|
||||
[[nodiscard]] float Height() const;
|
||||
|
||||
/// Computes the distance of the two inner points of this capsule. @see Height.
|
||||
float LineLength() const { return l.Length(); }
|
||||
[[nodiscard]] float LineLength() const;
|
||||
/// Computes the diameter of this capsule.
|
||||
float Diameter() const { return 2.f * r;}
|
||||
[[nodiscard]] float Diameter() const;
|
||||
/// Returns the bottom-most point of this Capsule.
|
||||
/** <img src="CapsuleFunctions.png" />
|
||||
@note The bottom-most point is only a naming convention, and does not correspond to the bottom-most point along any world axis. The returned
|
||||
@@ -80,42 +89,42 @@ namespace J3ML::Geometry
|
||||
@note The bottom-most point of the capsule is different than the point l.a. The returned point is the point at the very far
|
||||
edge of this capsule, and does not lie on the internal line. See the attached diagram.
|
||||
@see Top(), l. */
|
||||
Vector3 Bottom() const { return l.A - UpDirection() * r;}
|
||||
[[nodiscard]] Vector3 Bottom() const;
|
||||
/// Returns the center point of this Capsule.
|
||||
/** <img src="doc/static/docs/CapsuleFunctions.png" />
|
||||
@return The point (l.a + l.b) / 2. This point is the center of mass for this capsule.
|
||||
@see l, Bottom(), Top(). */
|
||||
|
||||
Vector3 Center() const { return l.CenterPoint();}
|
||||
Vector3 Centroid() const; ///< [similarOverload: Center]
|
||||
[[nodiscard]] Vector3 Center() const;
|
||||
[[nodiscard]] Vector3 Centroid() const; ///< [similarOverload: Center]
|
||||
|
||||
/// Returns the direction from the bottommost point towards the topmost point of this Capsule.
|
||||
/** <img src="CapsuleFunctions.png" />
|
||||
@return The normalized direction vector from l.a to l.b.
|
||||
@see l. */
|
||||
Vector3 UpDirection() const;
|
||||
[[nodiscard]] Vector3 UpDirection() const;
|
||||
|
||||
/// Computes the volume of this Capsule.
|
||||
/** @return pi * r^2 * |b-a| + 4 * pi * r^2 / 3.
|
||||
@see SurfaceArea(). */
|
||||
float Volume() const;
|
||||
[[nodiscard]] float Volume() const;
|
||||
|
||||
/// Computes the surface area of this Capsule.
|
||||
/** @return 2 * pi * r * |b-a| + 4 * pi * r^2.
|
||||
@see Volume(). */
|
||||
float SurfaceArea() const;
|
||||
[[nodiscard]] float SurfaceArea() const;
|
||||
|
||||
/// Returns the cross-section circle at the given height of this Capsule.
|
||||
/** <img src="CapsuleFunctions.png" />
|
||||
@param l A normalized parameter between [0,1]. l == 0 returns a degenerate circle of radius 0 at the bottom of this Capsule, and l == 1
|
||||
will return a degenerate circle of radius 0 at the top of this Capsule. */
|
||||
//Circle CrossSection(float l) const;
|
||||
Circle CrossSection(float l) const;
|
||||
|
||||
Vector3 ExtremePoint(const Vector3& direction);
|
||||
|
||||
/// Returns the smallest AABB that encloses this capsule.
|
||||
/** @see MinimalEnclosingOBB(). */
|
||||
AABB MinimalEnclosingAABB() const;
|
||||
[[nodiscard]] AABB MinimalEnclosingAABB() const;
|
||||
|
||||
/// Returns the smallest OBB that encloses this capsule.
|
||||
/** @see MinimalEnclosingAABB(). */
|
||||
@@ -137,7 +146,7 @@ namespace J3ML::Geometry
|
||||
@note The topmost point of the capsule is different than the point l.b. The returned point is the point at the very far
|
||||
edge of this capsule, and does not lie on the internal line. See the attached diagram.
|
||||
@see Bottom(), l. */
|
||||
Vector3 Top() const;
|
||||
[[nodiscard]] Vector3 Top() const;
|
||||
|
||||
/// Applies a transformation to this capsule.
|
||||
/** @param transform The transformation to apply to this capsule. This transformation must be
|
162
include/J3ML/Geometry/Circle.hpp
Normal file
162
include/J3ML/Geometry/Circle.hpp
Normal file
@@ -0,0 +1,162 @@
|
||||
/// Josh's 3D Math Library
|
||||
/// A C++20 Library for 3D Math, Computer Graphics, and Scientific Computing.
|
||||
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
|
||||
/// Special Thanks to William Tomasine II and Maxine Hayes.
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file Circle.hpp
|
||||
/// @desc The Circle geometry object.
|
||||
/// @edit 2024-07-06
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
|
||||
namespace J3ML
|
||||
{
|
||||
|
||||
/// A two-dimensional circle in 3D space.
|
||||
/// This class represents both a hollow circle (only edge) and a solid circle (disc).
|
||||
class Circle
|
||||
{
|
||||
public:
|
||||
/// The center position of this circle.
|
||||
Vector3 Position;
|
||||
/// The normal direction of this circle.
|
||||
/** A circle is a two-dimensional object in 3D space. This normal vector (together with the Position)
|
||||
specifies the plane in which this circle lies in.
|
||||
This vector is always normalized. If you assign to this member directly, be sure to only assign normalized vectors. */
|
||||
Vector3 Normal;
|
||||
/// The radius of the circle.
|
||||
/** This parameter must be strictly positive to specify a non-degenerate circle. If zero is specified, this circle
|
||||
is considered to be degenerate. */
|
||||
float Radius;
|
||||
/// The default constructor does not initialize any members of this class.
|
||||
/** This means that the values of members Position, Normal, and Radius are all undefined after creating
|
||||
a new circle using this default constructor. Remember to assign them before use.
|
||||
@see Position, Normal, Radius. */
|
||||
Circle() {}
|
||||
/// Constructs a new circle by explicitly specifying the member variables.
|
||||
/** @param center The center point of the circle.
|
||||
@param normal The direction vector that specifies the orientation of this circle.
|
||||
This vector must be normalized, the constructor will not normalize the vector for you (for performance reasons).
|
||||
@param radius The radius of the circle.
|
||||
@see Position, Normal, Radius. */
|
||||
Circle(const Vector3& center, const Vector3& normal, float radius);
|
||||
|
||||
/// Returns a normalized direction vector to the 'U direction' of the circle.
|
||||
/** This vector lies on the plane of this circle.
|
||||
The U direction specifies the first basis vector of a local space of this circle. */
|
||||
Vector3 BasisU() const;
|
||||
/// Returns a normalized direction vector to the 'V direction' of the circle.
|
||||
/** This vector lies on the plane of this circle.
|
||||
The V direction specifies the second basis vector of a local space of this circle. */
|
||||
Vector3 BasisV() const;
|
||||
/// Returns a point at the edge of this circle.
|
||||
/** @param angleRadians The direction of the point to get. A full circle is generated by the range [0, 2*pi],
|
||||
but it is ok to pass in values outside this range.
|
||||
@note This function is equivalent to calling GetPoint(float angleRadians, float d) with a value of d == 1.
|
||||
@return A point in world space at the edge of this circle. */
|
||||
Vector3 GetPoint(float angleRadians) const;
|
||||
/// Returns a point inside this circle.
|
||||
/** @param angleRadians The direction of the point to get. A full circle is generated by the range [0, 2*pi],
|
||||
but it is ok to pass in values outside this range.
|
||||
@param d A value in the range [0, 1] that specifies the normalized distance of the point from the center of the circle.
|
||||
A value of 0 returns the center point of this circle. A value of 1 returns a point at the edge of this circle.
|
||||
The range of d is not restricted, so it is ok to pass in values larger than 1 to generate a point lying completely
|
||||
outside the circle. */
|
||||
Vector3 GetPoint(float angleRadians, float d) const;
|
||||
|
||||
/// Returns the center point of this circle.
|
||||
/** This point is also the center of mass for this circle. The functions CenterPoint() and Centroid() are equivalent.
|
||||
@see Position. */
|
||||
Vector3 CenterPoint() const { return Position; }
|
||||
Vector3 Centroid() const { return Position;}
|
||||
|
||||
/// Computes an extreme point of this Circle/Disc in the given direction.
|
||||
/** An extreme point is a farthest point of this Circle/Disc in the given direction. Given a direction,
|
||||
this point is not necessarily unique.
|
||||
@param direction The direction vector of the direction to find the extreme point. This vector may
|
||||
be unnormalized, but may not be null.
|
||||
@return An extreme point of this Circle/Disc in the given direction. The returned point is always at
|
||||
the edge of this Circle. */
|
||||
Vector3 ExtremePoint(const Vector3& direction) const;
|
||||
|
||||
/// Computes the plane this circle is contained in.
|
||||
/** All of the points of this circle lie inside this plane.
|
||||
@see class Plane. */
|
||||
Plane ContainingPlane() const;
|
||||
|
||||
/// Translates this Circle in world space.
|
||||
/** @param offset The amount of displacement to apply to this circle, in world space coordinates.
|
||||
@see Transform(). */
|
||||
void Translate(const Vector3& offset);
|
||||
|
||||
/// Applies a transformation to this Circle.
|
||||
/** @param transform The transformation to apply to this Circle. This transformation must be
|
||||
affine, and must contain an orthogonal set of column vectors (may not contain shear or projection).
|
||||
The transformation can only contain uniform scale, and may not contain mirroring.
|
||||
@see Translate(), Scale(), classes Matrix3x3, Matrix4x4, Quaternion. */
|
||||
void Transform(const Matrix3x3& transform);
|
||||
void Transform(const Matrix4x4& transform);
|
||||
void Transform(const Quaternion& transform);
|
||||
|
||||
/// Tests if the given point is contained at the edge of this circle.
|
||||
/** @param point The target point to test.
|
||||
@param maxDistance The epsilon threshold to test the distance against. This effectively turns the circle into a torus
|
||||
for this test.
|
||||
@see DistanceToEdge(), DistanceToDisc(), ClosestPointToEdge(), ClosestPointToDisc().
|
||||
@todo Implement DiscContains(Vector3/LineSegment/Triangle). */
|
||||
bool EdgeContains(const Vector3& point, float maxDistance = 1e-6f) const;
|
||||
|
||||
/// Computes the distance of the given object to the edge of this circle.
|
||||
/** @todo Implement DistanceToEdge(Ray/LineSegment/Line).
|
||||
@return The distance of the given point to the edge of this circle. If the point is contained on this circle,
|
||||
the value 0 is returned.
|
||||
@see DistanceToEdge(), DistanceToDisc(), ClosestPointToDisc().*/
|
||||
float DistanceToEdge(const Vector3& point) const;
|
||||
|
||||
/// Computes the distance of the given object to this disc (filled circle).
|
||||
/** If the point is contained inside this disc, the value 0 is returned.
|
||||
@see DistanceToEdge(), ClosestPointToEdge(), ClosestPointToDisc().
|
||||
@todo Implement DistanceToDisc(Ray/LineSegment/Line). */
|
||||
float DistanceToDisc(const Vector3& point) const;
|
||||
|
||||
/// Computes the closest point on the edge of this circle to the given object.
|
||||
/** @todo Implement ClosestPointToEdge(Ray/LineSegment/Line).
|
||||
@see DistanceToEdge(), DistanceToDisc(), ClosestPointToDisc(). */
|
||||
Vector3 ClosestPointToEdge(const Vector3& point) const;
|
||||
|
||||
/// Computes the closest point on the disc of this circle to the given object.
|
||||
/** @todo Implement ClosestPointToDisc(Ray/LineSegment/Line).
|
||||
@see DistanceToEdge(), DistanceToDisc(), ClosestPointToEdge(). */
|
||||
Vector3 ClosestPointToDisc(const Vector3& point) const;
|
||||
|
||||
/// Tests this circle for an intersection against the given plane.
|
||||
/** @note For Circle-Plane intersection, there is no need to differentiate between a hollow or filled circle(disc).
|
||||
@return The number of intersection points found for this circle and the given plane.
|
||||
@see IntersectsDisc(). */
|
||||
int Intersects(const Plane& plane, Vector3* pt1, Vector3* pt2) const;
|
||||
int Intersects(const Plane& plane) const;
|
||||
|
||||
/// Tests this disc for an intersection against the given object.
|
||||
/** @see Intersects(). */
|
||||
bool IntersectsDisc(const Line& line) const;
|
||||
bool IntersectsDisc(const LineSegment& lineSegment) const;
|
||||
bool IntersectsDisc(const Ray& ray) const;
|
||||
|
||||
/// Tests if this circle intersects the faces of the given OBB.
|
||||
/** @param obb The bounding box to test against. This box is treated as "hollow", i.e. only the faces of the OBB are considered to be
|
||||
a part of the OBB.
|
||||
@return A vector that contains all the detected points of intersection for this circle and the given OBB. If the circle is fully
|
||||
contained inside the OBB, or is fully outside the OBB, no intersection occurs, and the returned vector has zero elements.
|
||||
@see Intersects(), IntersectsDisc(). */
|
||||
std::vector<Vector3> IntersectsFaces(const OBB& obb) const;
|
||||
std::vector<Vector3> IntersectsFaces(const AABB& aabb) const;
|
||||
};
|
||||
Circle operator *(const Matrix3x3& transform, const Circle& circle);
|
||||
Circle operator *(const Matrix4x4& transform, const Circle& circle);
|
||||
Circle operator *(const Quaternion& transform, const Circle& circle);
|
||||
std::ostream& operator << (std::ostream& o, const Circle& circle);
|
||||
}
|
@@ -3,10 +3,10 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include "Plane.h"
|
||||
#include "Shape.h"
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include "Plane.hpp"
|
||||
#include "Shape.hpp"
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "LineSegment.h"
|
||||
#include "LineSegment.hpp"
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Polyhedron.h>
|
||||
#include <J3ML/Geometry/Polyhedron.hpp>
|
||||
|
||||
|
||||
namespace J3ML::Geometry {
|
@@ -13,11 +13,11 @@
|
||||
|
||||
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Polyhedron.h>
|
||||
#include <J3ML/Geometry/Plane.h>
|
||||
#include <J3ML/Geometry/Polyhedron.hpp>
|
||||
#include <J3ML/Geometry/Plane.hpp>
|
||||
|
||||
#include "Sphere.h"
|
||||
#include "Sphere.h"
|
||||
#include "Sphere.hpp"
|
||||
#include "Sphere.hpp"
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include "Shape.h"
|
||||
#include "Ray.h"
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include "Shape.hpp"
|
||||
#include "Ray.hpp"
|
||||
|
||||
|
||||
namespace J3ML::Geometry
|
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <vector>
|
||||
#include "Shape.h"
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include "Shape.hpp"
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
|
||||
namespace J3ML::Geometry {
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Shape.h>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <J3ML/Geometry/Shape.hpp>
|
||||
#include <vector>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
|
||||
|
||||
namespace J3ML::Geometry
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
#include <J3ML/Geometry/AABB2D.hpp>
|
||||
|
||||
namespace J3ML::Geometry {
|
@@ -10,11 +10,11 @@
|
||||
/// @edit 2024-07-06
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <vector>
|
||||
#include "TriangleMesh.h"
|
||||
#include "Frustum.h"
|
||||
#include "OBB.h"
|
||||
#include "TriangleMesh.hpp"
|
||||
#include "Frustum.hpp"
|
||||
#include "OBB.hpp"
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
class GeometricPrimitive
|
@@ -12,12 +12,12 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <J3ML/Geometry.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.h>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include <J3ML/Geometry/TriangleMesh.h>
|
||||
#include <J3ML/Geometry/Shape.h>
|
||||
#include <J3ML/Geometry.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.hpp>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include <J3ML/Geometry/TriangleMesh.hpp>
|
||||
#include <J3ML/Geometry/Shape.hpp>
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "J3ML/LinearAlgebra/Vector3.h"
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include "J3ML/LinearAlgebra/Vector3.hpp"
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <cfloat>
|
||||
|
||||
namespace J3ML::Geometry
|
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/J3ML.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
|
||||
using namespace J3ML::LinearAlgebra;
|
@@ -15,16 +15,16 @@
|
||||
|
||||
// Library Code //
|
||||
|
||||
#include "J3ML/LinearAlgebra/Vector2.h"
|
||||
#include "J3ML/LinearAlgebra/Vector3.h"
|
||||
#include "J3ML/LinearAlgebra/Vector4.h"
|
||||
#include "J3ML/LinearAlgebra/Quaternion.h"
|
||||
#include "J3ML/LinearAlgebra/AxisAngle.h"
|
||||
#include "J3ML/LinearAlgebra/EulerAngle.h"
|
||||
#include "J3ML/LinearAlgebra/Matrix2x2.h"
|
||||
#include "J3ML/LinearAlgebra/Matrix3x3.h"
|
||||
#include "J3ML/LinearAlgebra/Matrix4x4.h"
|
||||
#include "J3ML/LinearAlgebra/Transform2D.h"
|
||||
#include "J3ML/LinearAlgebra/CoordinateFrame.h"
|
||||
#include "J3ML/LinearAlgebra/Vector2.hpp"
|
||||
#include "J3ML/LinearAlgebra/Vector3.hpp"
|
||||
#include "J3ML/LinearAlgebra/Vector4.hpp"
|
||||
#include "J3ML/LinearAlgebra/Quaternion.hpp"
|
||||
#include "J3ML/LinearAlgebra/AxisAngle.hpp"
|
||||
#include "J3ML/LinearAlgebra/EulerAngle.hpp"
|
||||
#include "J3ML/LinearAlgebra/Matrix2x2.hpp"
|
||||
#include "J3ML/LinearAlgebra/Matrix3x3.hpp"
|
||||
#include "J3ML/LinearAlgebra/Matrix4x4.hpp"
|
||||
#include "J3ML/LinearAlgebra/Transform2D.hpp"
|
||||
#include "J3ML/LinearAlgebra/CoordinateFrame.hpp"
|
||||
|
||||
using namespace J3ML::LinearAlgebra;
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <J3ML/J3ML.h>
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/EulerAngle.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/EulerAngle.hpp>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
/// Template Parameterized (Generic) Matrix Functions.
|
||||
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/J3ML.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
@@ -148,8 +148,8 @@ namespace J3ML::LinearAlgebra {
|
||||
template<typename Matrix>
|
||||
void Set3x3PartRotateX(Matrix &m, float angle) {
|
||||
float sinz, cosz;
|
||||
sinz = std::sin(angle);
|
||||
cosz = std::cos(angle);
|
||||
sinz = Math::Sin(angle);
|
||||
cosz = Math::Cos(angle);
|
||||
|
||||
m[0][0] = 1.f;
|
||||
m[0][1] = 0.f;
|
||||
@@ -170,8 +170,8 @@ namespace J3ML::LinearAlgebra {
|
||||
template<typename Matrix>
|
||||
void Set3x3PartRotateY(Matrix &m, float angle) {
|
||||
float sinz, cosz;
|
||||
sinz = std::sin(angle);
|
||||
cosz = std::cos(angle);
|
||||
sinz = Math::Sin(angle);
|
||||
cosz = Math::Cos(angle);
|
||||
|
||||
m[0][0] = cosz;
|
||||
m[0][1] = 0.f;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include "Vector.h"
|
||||
#include "Vector.hpp"
|
||||
|
||||
namespace J3ML::LinearAlgebra
|
||||
{
|
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
@@ -2,10 +2,10 @@
|
||||
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/EulerAngle.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
#include <J3ML/LinearAlgebra/EulerAngle.hpp>
|
||||
#include <J3ML/Algorithm/RNG.hpp>
|
||||
|
||||
using namespace J3ML::Algorithm;
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
#include <J3ML/Algorithm/RNG.hpp>
|
||||
|
||||
#include <algorithm>
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
#include <J3ML/Algorithm/RNG.hpp>
|
||||
#include <cmath>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
class Transform2D {
|
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <J3ML/LinearAlgebra/Angle2D.h>
|
||||
#include <J3ML/LinearAlgebra/Angle2D.hpp>
|
||||
#include <J3ML/Algorithm/RNG.hpp>
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include <cstddef>
|
||||
#include <cmath>
|
||||
|
||||
#include <J3ML/LinearAlgebra/Common.h>
|
||||
#include <J3ML/LinearAlgebra/Common.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
4
main.cpp
4
main.cpp
@@ -11,8 +11,8 @@
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <J3ML/Geometry.h>
|
||||
#include <J3ML/J3ML.h>
|
||||
#include <J3ML/Geometry.hpp>
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <J3ML/Algorithm/GJK.hpp>
|
||||
|
||||
#include <J3ML/Geometry.h>
|
||||
#include <J3ML/Geometry.hpp>
|
||||
|
||||
namespace J3ML::Algorithms
|
||||
{
|
||||
|
@@ -1,16 +1,16 @@
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <cassert>
|
||||
#include <J3ML/Geometry/Plane.h>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/Plane.hpp>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
//#include <J3ML/Geometry/OBB.h>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include <J3ML/Geometry/Triangle.h>
|
||||
#include <J3ML/Geometry/Polygon.h>
|
||||
#include <J3ML/Geometry/Frustum.h>
|
||||
#include <J3ML/Geometry/Capsule.h>
|
||||
#include <J3ML/Geometry/Ray.h>
|
||||
#include <J3ML/Geometry/TriangleMesh.h>
|
||||
#include <J3ML/Geometry/Polyhedron.h>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include <J3ML/Geometry/Triangle.hpp>
|
||||
#include <J3ML/Geometry/Polygon.hpp>
|
||||
#include <J3ML/Geometry/Frustum.hpp>
|
||||
#include <J3ML/Geometry/Capsule.hpp>
|
||||
#include <J3ML/Geometry/Ray.hpp>
|
||||
#include <J3ML/Geometry/TriangleMesh.hpp>
|
||||
#include <J3ML/Geometry/Polyhedron.hpp>
|
||||
#include <J3ML/Algorithm/RNG.hpp>
|
||||
|
||||
namespace J3ML::Geometry {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include <J3ML/Algorithm/GJK.hpp>
|
||||
#include <J3ML/Geometry/Capsule.h>
|
||||
#include <J3ML/Geometry/Capsule.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/Polygon.h>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
#include <J3ML/Geometry/Polygon.hpp>
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
@@ -138,4 +138,57 @@ namespace J3ML::Geometry
|
||||
{
|
||||
return Capsule(l.A + offset, l.B + offset, r);
|
||||
}
|
||||
|
||||
Vector3 Capsule::Bottom() const { return l.A - UpDirection() * r;}
|
||||
|
||||
Vector3 Capsule::Center() const { return l.CenterPoint();}
|
||||
|
||||
Vector3 Capsule::Centroid() const { return Center(); }
|
||||
|
||||
float Capsule::Diameter() const { return 2.f * r;}
|
||||
|
||||
float Capsule::LineLength() const { return l.Length(); }
|
||||
|
||||
void Capsule::SetFrom(const Sphere &s) {
|
||||
l = LineSegment(s.Position, s.Position);
|
||||
r = s.Radius;
|
||||
}
|
||||
|
||||
|
||||
void Capsule::SetDegenerate() {
|
||||
r = -1.f;
|
||||
}
|
||||
|
||||
Vector3 Capsule::AnyPointFast() const { return l.A; }
|
||||
|
||||
|
||||
Vector3 Capsule::UniformPointPerhapsInside(float height, float x, float y) const {
|
||||
return MinimalEnclosingOBB().PointInside(height, x, y);
|
||||
}
|
||||
|
||||
|
||||
Vector3 Capsule::UpDirection() const
|
||||
{
|
||||
Vector3 d = l.B - l.A;
|
||||
d.Normalize(); // Will always result in a normalized vector, even if l.a == l.b.
|
||||
return d;
|
||||
}
|
||||
|
||||
Vector3 Capsule::Top() const
|
||||
{
|
||||
return l.B + UpDirection() * r;
|
||||
}
|
||||
|
||||
float Capsule::Volume() const
|
||||
{
|
||||
return Math::Pi * r * r * LineLength() + 4.f * Math::Pi * r * r * r / 3.f;
|
||||
}
|
||||
|
||||
float Capsule::SurfaceArea() const
|
||||
{
|
||||
return 2.f * Math::Pi * r * LineLength() + 4.f * Math::Pi * r * r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
1
src/J3ML/Geometry/Circle.cpp
Normal file
1
src/J3ML/Geometry/Circle.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <J3ML/Geometry/Circle.hpp>
|
@@ -1,4 +1,4 @@
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
|
||||
namespace J3ML::Geometry {
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Frustum.h>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <J3ML/Geometry/Frustum.hpp>
|
||||
#include <cmath>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Polyhedron.h>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include <J3ML/Geometry/Polygon.h>
|
||||
#include <J3ML/Geometry/Polyhedron.hpp>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include <J3ML/Geometry/Polygon.hpp>
|
||||
#include <J3ML/Algorithm/GJK.hpp>
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/Geometry/Line.h>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <J3ML/Geometry/Line.hpp>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include "J3ML/Geometry/Capsule.h"
|
||||
#include <J3ML/Geometry/Line.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/Geometry/Plane.h>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include "J3ML/Geometry/Capsule.hpp"
|
||||
#include <J3ML/Geometry/Line.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
#include <J3ML/Geometry/Plane.hpp>
|
||||
|
||||
namespace J3ML::Geometry {
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include <J3ML/Geometry/Shape.h>
|
||||
#include <J3ML/Geometry/Shape.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include <J3ML/Geometry/Polyhedron.h>
|
||||
#include <J3ML/Geometry/OBB.h>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include <J3ML/Geometry/Polyhedron.hpp>
|
||||
#include <J3ML/Geometry/OBB.hpp>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
|
||||
namespace J3ML::Geometry {
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include <J3ML/Geometry/Plane.h>
|
||||
#include <J3ML/Geometry/Plane.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/OBB.h>
|
||||
#include <J3ML/Geometry/Capsule.h>
|
||||
#include <J3ML/Geometry/Polygon.h>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/OBB.hpp>
|
||||
#include <J3ML/Geometry/Capsule.hpp>
|
||||
#include <J3ML/Geometry/Polygon.hpp>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include <J3ML/Geometry/Polygon.h>
|
||||
#include <J3ML/Geometry/Polygon.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Triangle.h>
|
||||
#include "J3ML/Geometry/Plane.h"
|
||||
#include "J3ML/Geometry/Line.h"
|
||||
#include <J3ML/Geometry/Triangle.hpp>
|
||||
#include "J3ML/Geometry/Plane.hpp"
|
||||
#include "J3ML/Geometry/Line.hpp"
|
||||
#include <J3ML/Algorithm/GJK.hpp>
|
||||
|
||||
namespace J3ML::Geometry {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
#include <J3ML/Geometry/Polyhedron.h>
|
||||
#include <J3ML/Geometry/Polyhedron.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/Triangle.h>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include "J3ML/Geometry/Ray.h"
|
||||
#include "J3ML/Geometry/Line.h"
|
||||
#include <J3ML/Geometry/Polygon.h>
|
||||
#include <J3ML/Geometry/Capsule.h>
|
||||
#include <J3ML/Geometry/Triangle.hpp>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include "J3ML/Geometry/Ray.hpp"
|
||||
#include "J3ML/Geometry/Line.hpp"
|
||||
#include <J3ML/Geometry/Polygon.hpp>
|
||||
#include <J3ML/Geometry/Capsule.hpp>
|
||||
#include <set>
|
||||
#include <cfloat>
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <J3ML/Geometry/QuadTree.h>
|
||||
#include <J3ML/Geometry/QuadTree.hpp>
|
||||
|
||||
namespace Geometry
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include <J3ML/Geometry/Ray.h>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/Ray.hpp>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
|
||||
|
||||
namespace J3ML::Geometry
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include <J3ML/Geometry/Triangle.h>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/Geometry/Triangle.hpp>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <J3ML/Geometry/AABB.hpp>
|
||||
#include <J3ML/Geometry/LineSegment.h>
|
||||
#include <J3ML/Geometry/Line.h>
|
||||
#include <J3ML/Geometry/Capsule.h>
|
||||
#include <J3ML/Geometry/LineSegment.hpp>
|
||||
#include <J3ML/Geometry/Line.hpp>
|
||||
#include <J3ML/Geometry/Capsule.hpp>
|
||||
|
||||
namespace J3ML::Geometry
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <J3ML/Geometry/TriangleMesh.h>
|
||||
#include <J3ML/Geometry/TriangleMesh.hpp>
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
|
||||
TriangleMesh::TriangleMesh(int expectedPolygonCount) {
|
||||
//Vertices.reserve(expectedPolygonCount);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <format>
|
||||
#include <iomanip>
|
||||
#include <strstream>
|
||||
#include <J3ML/J3ML.h>
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
|
||||
float PowUInt(float base, u32 exponent)
|
||||
@@ -246,19 +246,19 @@ namespace J3ML
|
||||
outCos = Cos(x);
|
||||
}
|
||||
|
||||
float Asin(float x) { return std::asinf(x); }
|
||||
float Asin(float x) { return std::asin(x); }
|
||||
|
||||
float Acos(float x) { return std::acosf(x); }
|
||||
float Acos(float x) { return std::acos(x); }
|
||||
|
||||
float Atan(float x) { return std::atanf(x); }
|
||||
float Atan(float x) { return std::atan(x); }
|
||||
|
||||
float Atan2(float y, float x) { return std::atan2f(y, x); }
|
||||
float Atan2(float y, float x) { return std::atan2(y, x); }
|
||||
|
||||
float Sinh(float x) { return std::sinhf(x); }
|
||||
float Sinh(float x) { return std::sinh(x); }
|
||||
|
||||
float Cosh(float x) { return std::coshf(x); }
|
||||
float Cosh(float x) { return std::cosh(x); }
|
||||
|
||||
float Tanh(float x) { return std::tanhf(x); }
|
||||
float Tanh(float x) { return std::tanh(x); }
|
||||
|
||||
bool IsPow2(u32 number) {
|
||||
return (number & (number - 1)) == 0;
|
||||
@@ -276,7 +276,7 @@ namespace J3ML
|
||||
else return PowUInt(base, (u32) exponent);
|
||||
}
|
||||
|
||||
float Pow(float base, float exponent) { return std::powf(base, exponent); }
|
||||
float Pow(float base, float exponent) { return std::pow(base, exponent); }
|
||||
|
||||
float Exp(float exp) { return std::exp(exp); }
|
||||
|
||||
@@ -296,12 +296,12 @@ namespace J3ML
|
||||
return Log(10, value);
|
||||
}
|
||||
|
||||
float Ceil(float f) { return std::ceilf(f); }
|
||||
int CeilInt(float f) { return (int)std::ceilf(f);}
|
||||
float Ceil(float f) { return std::ceil(f); }
|
||||
int CeilInt(float f) { return (int)std::ceil(f);}
|
||||
|
||||
float Floor(float x) { return floorf(x); }
|
||||
float Floor(float x) { return std::floor(x); }
|
||||
|
||||
int FloorInt(float x) { return (int)floorf(x); }
|
||||
int FloorInt(float x) { return (int)std::floor(x); }
|
||||
|
||||
float Round(float x) { return Floor(x+0.5f); }
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include "J3ML/LinearAlgebra.h"
|
||||
#include "J3ML/LinearAlgebra.hpp"
|
||||
#include <cassert>
|
||||
|
||||
namespace LinearAlgebra {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.hpp>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
||||
AxisAngle::AxisAngle() : axis(Vector3::Zero) {}
|
||||
|
@@ -1 +1 @@
|
||||
#include <J3ML/LinearAlgebra/CoordinateFrame.h>
|
||||
#include <J3ML/LinearAlgebra/CoordinateFrame.hpp>
|
@@ -1,4 +1,4 @@
|
||||
#include <J3ML/LinearAlgebra/EulerAngle.h>
|
||||
#include <J3ML/LinearAlgebra/EulerAngle.hpp>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include <J3ML/LinearAlgebra/Matrix2x2.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix2x2.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrices.inl>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector4.hpp>
|
||||
#include <cmath>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrices.inl>
|
||||
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <J3ML/LinearAlgebra/Transform2D.h>
|
||||
#include <J3ML/LinearAlgebra/Transform2D.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <valarray>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <J3ML/Geometry/Sphere.h>
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
|
||||
|
@@ -2,8 +2,8 @@
|
||||
#pragma region vector4
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <jtest/jtest.hpp>
|
||||
|
||||
#include <J3ML/Geometry/Frustum.h>
|
||||
#include <J3ML/Geometry/Frustum.hpp>
|
||||
#include <J3ML/Geometry/PBVolume.hpp>
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/Geometry/Common.h>
|
||||
#include <J3ML/Geometry/Common.hpp>
|
||||
#include <jtest/jtest.hpp>
|
||||
using J3ML::Geometry::Interval;
|
||||
|
||||
|
10
tests/Geometry/OBBTests.hpp
Normal file
10
tests/Geometry/OBBTests.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
/// Josh's 3D Math Library
|
||||
/// A C++20 Library for 3D Math, Computer Graphics, and Scientific Computing.
|
||||
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
|
||||
/// Special Thanks to William Tomasine II and Maxine Hayes.
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file OBBTests.hpp
|
||||
/// @desc Unit tests for the Oriented Bounding Box class.
|
||||
/// @edit 2024-07-23
|
@@ -1,5 +1,5 @@
|
||||
#include <jtest/jtest.hpp>
|
||||
#include <J3ML/Geometry/Triangle.h>
|
||||
#include <J3ML/Geometry/Triangle.hpp>
|
||||
|
||||
using J3ML::Geometry::Interval;
|
||||
using J3ML::Geometry::Triangle;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
|
||||
using namespace J3ML::LinearAlgebra;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.hpp>
|
||||
#include <jtest/jtest.hpp>
|
||||
|
||||
using namespace J3ML::LinearAlgebra;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <jtest/jtest.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
|
||||
using namespace J3ML::LinearAlgebra;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.h>
|
||||
#include <J3ML/LinearAlgebra/Quaternion.hpp>
|
||||
|
||||
using namespace J3ML::LinearAlgebra;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
|
||||
using J3ML::LinearAlgebra::Vector3;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.hpp>
|
||||
|
||||
using Vector4 = J3ML::LinearAlgebra::Vector4;
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <jtest/jtest.hpp>
|
||||
#include <J3ML/J3ML.h>
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
inline void MathFuncTests()
|
||||
{
|
||||
|
Reference in New Issue
Block a user