HighMap library (C++)
Loading...
Searching...
No Matches
hmap::Point Class Reference

A class to represent and manipulate 2D points that can carry a value. More...

#include <point.hpp>

Public Member Functions

 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.
 

Public Attributes

float x
 The x-coordinate of the point.
 
float y
 The y-coordinate of the point.
 
float v
 The value at the point.
 

Friends

Point operator* (float scalar, const Point &point)
 Scalar multiplication (scalar * Vec2).
 

Detailed Description

A class to represent and manipulate 2D points that can carry a value.

Constructor & Destructor Documentation

◆ Point() [1/2]

hmap::Point::Point ( )
inline

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
xThe x-coordinate of the point.
yThe y-coordinate of the point.
vThe value at the point.

Member Function Documentation

◆ operator==()

bool hmap::Point::operator== ( const Point other) const
inline

Equality operator to check if two points are the same.

Parameters
otherThe 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
otherThe 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
otherThe point to add.
Returns
The result of adding the two points.

◆ operator-()

Point hmap::Point::operator- ( const Point other) const
inline

Subtracts two points.

Parameters
otherThe 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
scalarThe 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
scalarThe 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
arrayThe input Array from which the value is interpolated. The Array should support bilinear interpolation.
bboxBounding 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.

Friends And Related Symbol Documentation

◆ 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
scalarThe scalar value to multiply with.
pointThe vector to multiply.
Returns
Point A new vector with each component multiplied by the scalar.

Member Data Documentation

◆ x

float hmap::Point::x

The x-coordinate of the point.

◆ y

float hmap::Point::y

The y-coordinate of the point.

◆ v

float hmap::Point::v

The value at the point.


The documentation for this class was generated from the following files: