58 constexpr explicit Point(
const glm::vec2 &xy,
float v = 0.f) noexcept
67 constexpr explicit Point(
const glm::vec3 &xyv) noexcept
68 :
x(xyv.x),
y(xyv.y),
v(xyv.z)
80 constexpr glm::vec2
to_vec2() const noexcept
82 return glm::vec2(
x,
y);
89 constexpr glm::vec3
to_vec3() const noexcept
91 return glm::vec3(
x,
y,
v);
106 return (
x == other.x &&
y == other.y &&
v == other.v);
117 return !(*
this == other);
127 return Point(
x + other.x,
y + other.y,
v + other.v);
137 return Point(
x - other.x,
y - other.y,
v - other.v);
147 return Point(
x * scalar,
y * scalar,
v * scalar);
157 return Point(
x / scalar,
y / scalar,
v / scalar);
221 return Point(scalar * point.x, scalar * point.y, scalar * point.v);
258float angle(
const Point &p1,
const Point &p2);
268float angle(
const Point &p0,
const Point &p1,
const Point &p2);
286float cross_product(
const Point &p0,
const Point &p1,
const Point &p2);
305float curvature(
const Point &p1,
const Point &p2,
const Point &p3);
319float distance(
const Point &p1,
const Point &p2);
341 const Point &p_ctrl_start,
342 const Point &p_ctrl_end,
425Point
lerp(
const Point &p1,
const Point &p2,
float t);
440 float distance_ratio,
451Point
scale(
const Point &p, glm::vec2
scale, glm::vec2 center = {0.5f, 0.5f});
486 const Point &p_query);
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Axis-aligned 2D bounding box in world coordinates.
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
A class to represent and manipulate 2D points that can carry a value.
Definition point.hpp:26
constexpr Point operator-(const Point &other) const noexcept
Subtracts two points.
Definition point.hpp:135
void print() const
Prints the coordinates and value of the Point object.
Definition points.cpp:19
constexpr Point & operator/=(float scalar) noexcept
Divides this point by a scalar in-place.
Definition point.hpp:204
constexpr glm::vec2 to_vec2() const noexcept
Converts the point's coordinates to glm::vec2.
Definition point.hpp:80
constexpr glm::vec3 to_vec3() const noexcept
Converts the point's coordinates and value to glm::vec3.
Definition point.hpp:89
constexpr Point & operator-=(const Point &other) noexcept
Subtracts another point from this point in-place.
Definition point.hpp:178
constexpr bool operator==(const Point &other) const noexcept
Equality operator to check if two points are the same.
Definition point.hpp:104
constexpr Point & operator*=(float scalar) noexcept
Multiplies this point by a scalar in-place.
Definition point.hpp:191
void set_value_from_array(const Array &array, const BBox2D &bbox)
Updates the point's value based on bilinear interpolation from an array.
Definition points.cpp:25
friend constexpr Point operator*(float scalar, const Point &point) noexcept
Scalar multiplication (scalar * Point).
Definition point.hpp:219
constexpr Point operator+(const Point &other) const noexcept
Adds two points.
Definition point.hpp:125
constexpr Point(const glm::vec2 &xy, float v=0.f) noexcept
Constructs a Point from a glm::vec2 and an optional value.
Definition point.hpp:58
constexpr Point & operator+=(const Point &other) noexcept
Adds another point to this point in-place.
Definition point.hpp:165
float y
The y-coordinate of the point.
Definition point.hpp:29
constexpr Point(float x, float y, float v=0.f) noexcept
Parameterized constructor initializing the point to given values.
Definition point.hpp:49
float x
The x-coordinate of the point.
Definition point.hpp:28
constexpr Point(const glm::vec3 &xyv) noexcept
Constructs a Point from a glm::vec3 (x, y, v).
Definition point.hpp:67
float v
The value at the point.
Definition point.hpp:30
constexpr Point operator*(float scalar) const noexcept
Multiplies the point by a scalar.
Definition point.hpp:145
constexpr Point() noexcept
Default constructor initializing the point to (0, 0, 0).
Definition point.hpp:39
constexpr Point operator/(float scalar) const noexcept
Divides the point by a scalar.
Definition point.hpp:155
constexpr bool operator!=(const Point &other) const noexcept
Inequality operator to check if two points are different.
Definition point.hpp:115
bool is_point_within_bounding_box(const Point &p, const BBox2D &bbox)
Checks if a point is within a specified bounding box.
Definition points.cpp:253
float side(const Point &p1, const Point &p2, const Point &p3, const Point &p_query)
Determines the relative side of a query point with respect to a curve segment.
Definition points.cpp:332
float curvature(const Point &p1, const Point &p2, const Point &p3)
Calculates the curvature formed by three points in 2D space.
Definition points.cpp:119
Point midpoint(const Point &p1, const Point &p2, int orientation, float distance_ratio, float t=0.5f)
Computes the midpoint displacement with a perpendicular offset.
Definition points.cpp:272
float distance(const Point &p1, const Point &p2)
Calculates the Euclidean distance between two points.
Definition points.cpp:145
float triangle_area_signed(const Point &p1, const Point &p2, const Point &p3)
Calculates the signed area of a triangle formed by three points.
Definition points.cpp:373
float classify_point(const Point &p_prev, const Point &p, const Point &p_next, const Point &pq)
Classify point convexity relative to neighboring curve vertices.
Definition points.cpp:94
void sort_points(std::vector< Point > &points)
Sorts a vector of points in ascending order (x, then y, then v).
Definition points.cpp:363
Cloud scale(const Cloud &cloud, glm::vec2 scale, glm::vec2 center={0.5f, 0.5f})
Scales the point coordinates in a cloud relative to a center point.
Definition cloud_functions.cpp:163
float cross_product(const Point &p0, const Point &p1, const Point &p2)
Computes the 2D cross product of vectors (p1 - p0) and (p2 - p0).
Definition points.cpp:109
float distance_squared(const Point &p1, const Point &p2)
Calculates the squared Euclidean distance between two points.
Definition points.cpp:150
float triangle_area(const Point &p1, const Point &p2, const Point &p3)
Calculates the unsigned area of a triangle formed by three points.
Definition points.cpp:368
Point interp_decasteljau(const std::vector< Point > &points, float t)
Performs a De Casteljau algorithm-based interpolation for Bezier curves.
Definition points.cpp:218
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:65
float curvature_signed(const Point &p1, const Point &p2, const Point &p3)
Calculates the signed curvature formed by three points in 2D space.
Definition points.cpp:132
Point lerp(const Point &p1, const Point &p2, float t)
Linearly interpolates between two points.
Definition points.cpp:265
BBox2D unit_square_bbox()
Constructs a 4D bounding box for a unit square {0, 1, 0, 1}.
Definition points.cpp:379
Point interp_bezier(const Point &p_start, const Point &p_ctrl_start, const Point &p_ctrl_end, const Point &p_end, float t)
Performs a cubic Bezier interpolation.
Definition points.cpp:157
Point interp_catmullrom(const Point &p0, const Point &p1, const Point &p2, const Point &p3, float t)
Performs a Catmull-Rom spline interpolation.
Definition points.cpp:199
BBox2D intersect_bounding_boxes(const BBox2D &bbox1, const BBox2D &bbox2)
Determines the intersection of two bounding boxes.
Definition points.cpp:237
std::optional< Point > segment_intersection(const Point &p1, const Point &p2, const Point &q1, const Point &q2)
Computes the intersection point of two 2D segments, if it exists.
Definition points.cpp:305
Point interp_bspline(const Point &p0, const Point &p1, const Point &p2, const Point &p3, float t)
Performs a cubic B-spline interpolation.
Definition points.cpp:180
Axis-aligned 2D bounding box in world coordinates.
Definition bbox2d.hpp:25