Fixed undefined reference in Bezier curve. Other additions and fixes included.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 58s
Build Docs With Doxygen / Explore-Gitea-Actions (push) Successful in 21s

This commit is contained in:
2024-08-05 15:14:06 -04:00
parent c10c63a7e1
commit 6aa7dc9745
11 changed files with 131 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ namespace J3ML::Algorithm
return Cube(1 - t) * p0 + 3 * Square(1 - t) * t * p1 + 3 * (1 - t) * Square(t) * p2 + Cube(t) * p3;
}
inline Vector2 Bezier(float t, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3);
Vector2 Bezier(float t, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3);
// Tangent
Vector2 BezierDerivative(float t, const Vector2& p0, const Vector2& p1, const Vector2& p2, const Vector2& p3);

View File

@@ -1,3 +1,14 @@
/// 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 AABB.hpp
/// @desc The Axis-Aligned Bounding Box geometry object.
/// @edit 2024-08-01
#pragma once
#include <format>

View File

@@ -1,3 +1,15 @@
/// 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 AABB2D.hpp
/// @desc A 2D Axis-Aligned Bounding Box structure.
/// @edit 2024-08-01
/// @note On backlog, low-priority.
#pragma once
#include <J3ML/LinearAlgebra/Vector2.hpp>

View File

@@ -1,5 +1,15 @@
#pragma once
/// 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 Capsule.hpp
/// @desc The Capsule geometry object.
/// @edit 2024-08-01
#pragma once
#include <J3ML/LinearAlgebra/Common.hpp>
#include <J3ML/Geometry/Common.hpp>

View File

@@ -7,7 +7,7 @@
/// @file Circle.hpp
/// @desc The Circle geometry object.
/// @edit 2024-07-06
/// @edit 2024-08-01
#pragma once

View File

@@ -1,3 +1,14 @@
/// 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 Polygon.hpp
/// @desc The Polygon geometry object.
/// @edit 2024-08-01
#pragma once
#include <J3ML/Geometry/Common.hpp>

View File

@@ -1,3 +1,15 @@
/// 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 Matrix.hpp
/// @desc Templated implementation of arbitrary-sized N-by-M matrices.
/// @edit 2024-08-01
/// @note On backlog, low-priority.
#pragma once
#include <cstddef>

View File

@@ -1,3 +1,15 @@
/// 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 Matrix2x2.hpp
/// @desc A two-by-two Matrix object.
/// @edit 2024-08-01
/// @note On backlog, low-priority.
#pragma once

View File

@@ -220,6 +220,17 @@ public:
@see AnotherPerpendicular(), Cross(). */
[[nodiscard]] Vector3 Perpendicular(const Vector3 &hint = Vector3(0,1,0), const Vector3 &hint2 = Vector3(0,0,1)) const;
/// Returns another vector that is perpendicular to this vector and the vector returned by Perpendicular().
/** The set (this, Perpendicular(), AnotherPerpendicular()) forms a right-handed normalized 3D basis.
@see Perpendicular(), Cross(). */
Vector3 AnotherPerpendicular(const Vector3& hint = Vector3(0,1,0), const Vector3& hint2 = Vector3(0,0,1)) const;
/// Returns a scaled copy of this vector which has its new length as given.
/** This function assumes the length of this vector is not zero. In the case of failure, an error message is printed,
and the vector (newLength, 0, 0) is returned.
@see ScaleToLength(). */
Vector3 ScaledToLength(float newLength) const;
[[nodiscard]] Vector3 Min(const Vector3& min) const;
static Vector3 Min(const Vector3& a, const Vector3& b, const Vector3& c);
static Vector3 Min(const Vector3& lhs, const Vector3& rhs);

View File

@@ -1 +1,38 @@
#include <J3ML/Geometry/Circle.hpp>
#include <J3ML/Geometry/Circle.hpp>
namespace J3ML
{
Circle::Circle(const Vector3& center, const Vector3& norm, float radius)
: Position(center), Normal(norm), Radius(radius)
{}
Vector3 Circle::BasisU() const { return Normal.Perpendicular(); }
Vector3 Circle::BasisV() const { return Normal.AnotherPerpendicular();}
Vector3 Circle::GetPoint(float angleRadians) const
{
float sin, cos;
Math::SinCos(angleRadians, sin, cos);
return Position + Radius * (sin * BasisU() + cos * BasisV());
}
Vector3 Circle::GetPoint(float angleRadians, float d) const
{
float sin, cos;
Math::SinCos(angleRadians, sin, cos);
return Position + Radius * d * (sin * BasisU() + cos * BasisV());
}
Vector3 Circle::ExtremePoint(const Vector3& direction) const
{
Vector3 d = direction - direction.ProjectToNorm(Normal);
if (d.IsZero())
return Position;
else
return Position + d.ScaledToLength(Radius);
}
}

View File

@@ -484,6 +484,17 @@ namespace J3ML::LinearAlgebra {
return Vector3::Zero;
}
Vector3 Vector3::AnotherPerpendicular(const J3ML::LinearAlgebra::Vector3 &hint,
const J3ML::LinearAlgebra::Vector3 &hint2) const {
assert(!this->IsZero());
assert(hint.IsNormalized());
assert(hint2.IsNormalized());
Vector3 firstPerpendicular = Perpendicular(hint, hint2);
Vector3 v = this->Cross(firstPerpendicular);
return v.Normalized();
}
float Vector3::TryNormalize() {
assert(IsFinite());
float length = Length();