Skip to content

Commit

Permalink
Rename Segment to LineSegment
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Feb 27, 2024
1 parent 727054a commit 4f83e65
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/OpenSimCreator/Graphics/OpenSimDecorationGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <oscar/Graphics/Scene/SceneHelpers.h>
#include <oscar/Maths/AABB.h>
#include <oscar/Maths/GeometricFunctions.h>
#include <oscar/Maths/LineSegment.h>
#include <oscar/Maths/MathHelpers.h>
#include <oscar/Maths/Segment.h>
#include <oscar/Maths/QuaternionFunctions.h>
#include <oscar/Maths/Transform.h>
#include <oscar/Maths/Vec3.h>
Expand Down
4 changes: 2 additions & 2 deletions src/OpenSimCreator/Graphics/SimTKDecorationGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <oscar/Graphics/Color.h>
#include <oscar/Graphics/Scene/SceneCache.h>
#include <oscar/Graphics/Scene/SceneDecoration.h>
#include <oscar/Maths/LineSegment.h>
#include <oscar/Maths/MathHelpers.h>
#include <oscar/Maths/Segment.h>
#include <oscar/Maths/Vec3.h>
#include <oscar/Platform/Log.h>
#include <oscar/Utils/HashHelpers.h>
Expand Down Expand Up @@ -266,7 +266,7 @@ namespace
Vec3 direction = {0.0f, 0.0f, 0.0f};
direction[axis] = 1.0f;

Segment const line =
LineSegment const line =
{
t.position,
t.position + (legLen * axisLengths[axis] * transform_direction(t, direction))
Expand Down
2 changes: 1 addition & 1 deletion src/oscar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ add_library(oscar STATIC
Maths/Functors.h
Maths/GeometricFunctions.h
Maths/Line.h
Maths/LineSegment.h
Maths/Mat.h
Maths/MatFunctions.h
Maths/MathHelpers.h
Expand All @@ -172,7 +173,6 @@ add_library(oscar STATIC
Maths/QuaternionFunctions.h
Maths/RayCollision.h
Maths/Rect.h
Maths/Segment.h
Maths/Sphere.h
Maths/Tetrahedron.h
Maths/Transform.h
Expand Down
4 changes: 2 additions & 2 deletions src/oscar/Graphics/Scene/SceneHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
#include <oscar/Maths/BVH.h>
#include <oscar/Maths/CollisionTests.h>
#include <oscar/Maths/Line.h>
#include <oscar/Maths/LineSegment.h>
#include <oscar/Maths/MathHelpers.h>
#include <oscar/Maths/PolarPerspectiveCamera.h>
#include <oscar/Maths/Quat.h>
#include <oscar/Maths/RayCollision.h>
#include <oscar/Maths/Rect.h>
#include <oscar/Maths/Segment.h>
#include <oscar/Maths/Transform.h>
#include <oscar/Maths/Vec2.h>
#include <oscar/Maths/Vec3.h>
Expand Down Expand Up @@ -188,7 +188,7 @@ void osc::DrawArrow(

void osc::DrawLineSegment(
SceneCache& cache,
Segment const& segment,
LineSegment const& segment,
Color const& color,
float radius,
std::function<void(SceneDecoration&&)> const& out)
Expand Down
4 changes: 2 additions & 2 deletions src/oscar/Graphics/Scene/SceneHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace osc { class BVH; }
namespace osc { class Mesh; }
namespace osc { struct PolarPerspectiveCamera; }
namespace osc { struct Rect; }
namespace osc { struct Segment; }
namespace osc { struct LineSegment; }
namespace osc { class SceneCache; }
namespace osc { class ShaderCache; }
namespace osc { struct Transform; }
Expand Down Expand Up @@ -90,7 +90,7 @@ namespace osc

void DrawLineSegment(
SceneCache&,
Segment const&,
LineSegment const&,
Color const&,
float radius,
std::function<void(SceneDecoration&&)> const&
Expand Down
2 changes: 1 addition & 1 deletion src/oscar/Maths.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <oscar/Maths/Functors.h>
#include <oscar/Maths/GeometricFunctions.h>
#include <oscar/Maths/Line.h>
#include <oscar/Maths/LineSegment.h>
#include <oscar/Maths/Mat.h>
#include <oscar/Maths/MatFunctions.h>
#include <oscar/Maths/MathHelpers.h>
Expand All @@ -33,7 +34,6 @@
#include <oscar/Maths/QuaternionFunctions.h>
#include <oscar/Maths/RayCollision.h>
#include <oscar/Maths/Rect.h>
#include <oscar/Maths/Segment.h>
#include <oscar/Maths/Sphere.h>
#include <oscar/Maths/Tetrahedron.h>
#include <oscar/Maths/Transform.h>
Expand Down
4 changes: 2 additions & 2 deletions src/oscar/Maths/Segment.h → src/oscar/Maths/LineSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

namespace osc
{
struct Segment final {
struct LineSegment final {
Vec3 p1{};
Vec3 p2{};
};

std::ostream& operator<<(std::ostream&, Segment const&);
std::ostream& operator<<(std::ostream&, LineSegment const&);
}
10 changes: 5 additions & 5 deletions src/oscar/Maths/MathHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace osc { struct Circle; }
namespace osc { struct Disc; }
namespace osc { struct Plane; }
namespace osc { struct Rect; }
namespace osc { struct Segment; }
namespace osc { struct LineSegment; }

// math helpers: generally handy math functions that aren't attached to a particular
// osc struct
Expand Down Expand Up @@ -177,16 +177,16 @@ namespace osc
// ----- `Segment` helpers -----

// returns a transform matrix that maps a path segment to another path segment
Mat4 SegmentToSegmentMat4(Segment const&, Segment const&);
Mat4 SegmentToSegmentMat4(LineSegment const&, LineSegment const&);

// returns a transform that maps a path segment to another path segment
Transform SegmentToSegmentTransform(Segment const&, Segment const&);
Transform SegmentToSegmentTransform(LineSegment const&, LineSegment const&);

// returns a transform that maps a Y-to-Y (bottom-to-top) cylinder to a segment with the given radius
Transform YToYCylinderToSegmentTransform(Segment const&, float radius);
Transform YToYCylinderToSegmentTransform(LineSegment const&, float radius);

// returns a transform that maps a Y-to-Y (bottom-to-top) cone to a segment with the given radius
Transform YToYConeToSegmentTransform(Segment const&, float radius);
Transform YToYConeToSegmentTransform(LineSegment const&, float radius);

// ----- other -----

Expand Down
14 changes: 7 additions & 7 deletions src/oscar/Maths/MathsImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,9 @@ std::ostream& osc::operator<<(std::ostream& o, Rect const& r)

// `Segment` implementation

std::ostream& osc::operator<<(std::ostream& o, Segment const& d)
std::ostream& osc::operator<<(std::ostream& o, LineSegment const& d)
{
return o << "Segment(p1 = " << d.p1 << ", p2 = " << d.p2 << ')';
return o << "LineSegment(p1 = " << d.p1 << ", p2 = " << d.p2 << ')';
}


Expand Down Expand Up @@ -1547,7 +1547,7 @@ std::optional<Rect> osc::AABBToScreenNDCRect(
return rv;
}

Mat4 osc::SegmentToSegmentMat4(Segment const& a, Segment const& b)
Mat4 osc::SegmentToSegmentMat4(LineSegment const& a, LineSegment const& b)
{
Vec3 a1ToA2 = a.p2 - a.p1;
Vec3 b1ToB2 = b.p2 - b.p1;
Expand All @@ -1572,7 +1572,7 @@ Mat4 osc::SegmentToSegmentMat4(Segment const& a, Segment const& b)
return move * rotate * scale(Identity<Mat4>(), scaler);
}

Transform osc::SegmentToSegmentTransform(Segment const& a, Segment const& b)
Transform osc::SegmentToSegmentTransform(LineSegment const& a, LineSegment const& b)
{
Vec3 aLine = a.p2 - a.p1;
Vec3 bLine = b.p2 - b.p1;
Expand All @@ -1595,16 +1595,16 @@ Transform osc::SegmentToSegmentTransform(Segment const& a, Segment const& b)
return t;
}

Transform osc::YToYCylinderToSegmentTransform(Segment const& s, float radius)
Transform osc::YToYCylinderToSegmentTransform(LineSegment const& s, float radius)
{
Segment cylinderLine{{0.0f, -1.0f, 0.0f}, {0.0f, 1.0f, 0.0f}};
LineSegment cylinderLine{{0.0f, -1.0f, 0.0f}, {0.0f, 1.0f, 0.0f}};
Transform t = SegmentToSegmentTransform(cylinderLine, s);
t.scale.x = radius;
t.scale.z = radius;
return t;
}

Transform osc::YToYConeToSegmentTransform(Segment const& s, float radius)
Transform osc::YToYConeToSegmentTransform(LineSegment const& s, float radius)
{
return YToYCylinderToSegmentTransform(s, radius);
}
Expand Down

0 comments on commit 4f83e65

Please sign in to comment.