A class to represent and manipulate 2D points that can carry a value.
More...
#include <point.hpp>
|
| Point () |
| Default constructor initializing the point to (0, 0, 0).
|
|
| Point (float x, float y, float v=0.f) |
| Parameterized constructor initializing the point to given values.
|
|
bool | operator== (const Point &other) const |
| Equality operator to check if two points are the same.
|
|
bool | operator!= (const Point &other) const |
| Inequality operator to check if two points are different.
|
|
Point | operator+ (const Point &other) const |
| Adds two points.
|
|
Point | operator- (const Point &other) const |
| Subtracts two points.
|
|
Point | operator* (float scalar) const |
| Multiplies the point by a scalar.
|
|
Point | operator/ (float scalar) const |
| Divides the point by a scalar.
|
|
void | print () |
| Prints the coordinates and value of the Point object.
|
|
void | set_value_from_array (const Array &array, Vec4< float > bbox) |
| Updates the point's value based on bilinear interpolation from an array.
|
|
|
float | x |
| The x-coordinate of the point.
|
|
float | y |
| The y-coordinate of the point.
|
|
float | v |
| The value at the point.
|
|
A class to represent and manipulate 2D points that can carry a value.
◆ Point() [1/2]
Default constructor initializing the point to (0, 0, 0).
◆ Point() [2/2]
hmap::Point::Point |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
v = 0.f |
|
) |
| |
|
inline |
Parameterized constructor initializing the point to given values.
- Parameters
-
x | The x-coordinate of the point. |
y | The y-coordinate of the point. |
v | The value at the point. |
◆ operator==()
bool hmap::Point::operator== |
( |
const Point & |
other | ) |
const |
|
inline |
Equality operator to check if two points are the same.
- Parameters
-
other | The point to compare with. |
- Returns
- true if the points are equal, false otherwise.
◆ operator!=()
bool hmap::Point::operator!= |
( |
const Point & |
other | ) |
const |
|
inline |
Inequality operator to check if two points are different.
- Parameters
-
other | The point to compare with. |
- Returns
- true if the points are not equal, false otherwise.
◆ operator+()
Point hmap::Point::operator+ |
( |
const Point & |
other | ) |
const |
|
inline |
Adds two points.
- Parameters
-
- Returns
- The result of adding the two points.
◆ operator-()
Point hmap::Point::operator- |
( |
const Point & |
other | ) |
const |
|
inline |
Subtracts two points.
- Parameters
-
other | The point to subtract. |
- Returns
- The result of subtracting the other point from this point.
◆ operator*()
Point hmap::Point::operator* |
( |
float |
scalar | ) |
const |
|
inline |
Multiplies the point by a scalar.
- Parameters
-
scalar | The scalar to multiply by. |
- Returns
- The result of the multiplication.
◆ operator/()
Point hmap::Point::operator/ |
( |
float |
scalar | ) |
const |
|
inline |
Divides the point by a scalar.
- Parameters
-
scalar | The scalar to divide by. |
- Returns
- The result of the division.
◆ print()
void hmap::Point::print |
( |
| ) |
|
Prints the coordinates and value of the Point object.
This function outputs the Point's x, y coordinates, and an additional value v
to the standard output in the format (x, y, v)
, followed by a newline.
◆ set_value_from_array()
void hmap::Point::set_value_from_array |
( |
const Array & |
array, |
|
|
Vec4< float > |
bbox |
|
) |
| |
Updates the point's value based on bilinear interpolation from an array.
This function updates the value of the Point
object by performing bilinear interpolation on the input Array
using the coordinates of the Point
and a given bounding box. The point's coordinates are first normalized to the unit interval using the provided bounding box. Then, these normalized coordinates are scaled to the array's dimensions and used to fetch the value from the array through bilinear interpolation.
If the normalized coordinates fall outside the bounds of the array, the point's value is set to zero.
- Parameters
-
array | The input Array from which the value is interpolated. The Array should support bilinear interpolation. |
bbox | Bounding box used for normalizing the Point 's coordinates. This box is defined by a Vec4<float> containing minimum and maximum values for both x and y dimensions in the format {xmin, xmax, ymin, ymax} . |
- Note
- If the coordinates are outside the bounds of the array after scaling, the point's value is set to zero.
◆ operator*
Point operator* |
( |
float |
scalar, |
|
|
const Point & |
point |
|
) |
| |
|
friend |
Scalar multiplication (scalar * Vec2).
Multiplies each component of the vector by a scalar value. This function allows expressions where the scalar is on the left side of the multiplication operator.
- Parameters
-
scalar | The scalar value to multiply with. |
point | The vector to multiply. |
- Returns
- Point A new vector with each component multiplied by the scalar.
The x-coordinate of the point.
The y-coordinate of the point.
The documentation for this class was generated from the following files: