HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends
hi::v1::vector3 Class Reference

#include <hikogui/geometry/vector3.hpp>

Public Types

using array_type = simd<float, 4>
 
using value_type = array_type::value_type
 

Public Member Functions

constexpr vector3 (vector3 const &) noexcept=default
 
constexpr vector3 (vector3 &&) noexcept=default
 
constexpr vector3operator= (vector3 const &) noexcept=default
 
constexpr vector3operator= (vector3 &&) noexcept=default
 
constexpr vector3 (vector2 const &other) noexcept
 Construct a vector from a lower dimension vector.
 
constexpr operator vector2 () noexcept
 Construct a vector from a higher dimension vector.
 
constexpr operator array_type () const noexcept
 Convert a vector to its array_type-nummeric_array.
 
constexpr vector3 (array_type const &other) noexcept
 Construct a vector from a array_type-simd.
 
constexpr vector3 () noexcept
 Construct a empty vector / zero length.
 
constexpr vector3 (float x, float y, float z=0.0f) noexcept
 Construct a 3D vector from x, y and z elements.
 
constexpr float & x () noexcept
 Access the x element from the vector.
 
constexpr float & y () noexcept
 Access the y element from the vector.
 
constexpr float & z () noexcept
 Access the z element from the vector.
 
constexpr float x () const noexcept
 Access the x element from the vector.
 
constexpr float y () const noexcept
 Access the y element from the vector.
 
constexpr float z () const noexcept
 Access the z element from the vector.
 
constexpr vector3 operator- () const noexcept
 Mirror this vector.
 
constexpr vector3operator+= (vector3 const &rhs) noexcept
 
constexpr vector3operator-= (vector3 const &rhs) noexcept
 
constexpr vector3operator*= (float const &rhs) noexcept
 
constexpr bool holds_invariant () const noexcept
 Check if the vector is valid.
 

Friends

constexpr friend vector3 operator+ (vector3 const &lhs, vector3 const &rhs) noexcept
 Add two vectors from each other.
 
constexpr friend vector3 operator- (vector3 const &lhs, vector3 const &rhs) noexcept
 Subtract two vectors from each other.
 
constexpr friend vector3 operator* (vector3 const &lhs, float const &rhs) noexcept
 Scale the vector by a scaler.
 
constexpr friend vector3 operator* (float const &lhs, vector3 const &rhs) noexcept
 Scale the vector by a scaler.
 
constexpr friend bool operator== (vector3 const &lhs, vector3 const &rhs) noexcept
 Compare if two vectors are equal.
 
constexpr friend float squared_hypot (vector3 const &rhs) noexcept
 Get the squared length of the vector.
 
float hypot (vector3 const &rhs) noexcept
 Get the length of the vector.
 
constexpr friend float rcp_hypot (vector3 const &rhs) noexcept
 Get the length of the vector.
 
constexpr friend vector3 normalize (vector3 const &rhs) noexcept
 Normalize a vector to a unit vector.
 
constexpr friend float dot (vector3 const &lhs, vector3 const &rhs) noexcept
 Get the dot product between two vectors.
 
constexpr friend vector3 normal (vector3 const &rhs, float angle) noexcept
 Get the normal on a 3D vector.
 
constexpr friend vector3 cross (vector3 const &lhs, vector3 const &rhs) noexcept
 Get the cross product between two 3D vectors.
 
constexpr vector3 min (vector3 const &lhs, vector3 const &rhs) noexcept
 Mix the two vectors and get the lowest value of each element.
 
constexpr vector3 max (vector3 const &lhs, vector3 const &rhs) noexcept
 Mix the two vectors and get the highest value of each element.
 
constexpr vector3 round (vector3 const &rhs) noexcept
 Round the elements of the vector toward nearest integer.
 
constexpr vector3 ceil (vector3 const &rhs) noexcept
 Round the elements of the vector toward upward and to the right.
 
constexpr vector3 floor (vector3 const &rhs) noexcept
 Round the elements of the vector toward downward and to the left.
 
std::string to_string (vector3 const &rhs) noexcept
 
std::ostreamoperator<< (std::ostream &lhs, vector3 const &rhs) noexcept
 

Detailed Description

A high-level geometric vector Part of the high-level vector, point, mat and color types.

A vector, for both 2D or 3D is internally represented as a 4D homogeneous vector. Which can be efficiently implemented as a __m128 SSE register.

Constructor & Destructor Documentation

◆ vector3() [1/4]

constexpr hi::v1::vector3::vector3 ( vector2 const & other)
inlineconstexprnoexcept

Construct a vector from a lower dimension vector.

◆ vector3() [2/4]

constexpr hi::v1::vector3::vector3 ( array_type const & other)
inlineexplicitconstexprnoexcept

Construct a vector from a array_type-simd.

◆ vector3() [3/4]

constexpr hi::v1::vector3::vector3 ( )
inlineconstexprnoexcept

Construct a empty vector / zero length.

◆ vector3() [4/4]

constexpr hi::v1::vector3::vector3 ( float x,
float y,
float z = 0.0f )
inlineconstexprnoexcept

Construct a 3D vector from x, y and z elements.

Parameters
xThe x element.
yThe y element.
zThe z element.

Member Function Documentation

◆ holds_invariant()

constexpr bool hi::v1::vector3::holds_invariant ( ) const
inlineconstexprnoexcept

Check if the vector is valid.

This function will check if w is zero, and with 2D vector is z is zero.

◆ operator array_type()

constexpr hi::v1::vector3::operator array_type ( ) const
inlineexplicitconstexprnoexcept

Convert a vector to its array_type-nummeric_array.

◆ operator vector2()

constexpr hi::v1::vector3::operator vector2 ( )
inlineexplicitconstexprnoexcept

Construct a vector from a higher dimension vector.

This will clear the values in the higher dimensions.

◆ operator-()

constexpr vector3 hi::v1::vector3::operator- ( ) const
inlineconstexprnoexcept

Mirror this vector.

Returns
The mirrored vector.

◆ x() [1/2]

constexpr float hi::v1::vector3::x ( ) const
inlineconstexprnoexcept

Access the x element from the vector.

Returns
a reference to the x element.

◆ x() [2/2]

constexpr float & hi::v1::vector3::x ( )
inlineconstexprnoexcept

Access the x element from the vector.

Returns
a reference to the x element.

◆ y() [1/2]

constexpr float hi::v1::vector3::y ( ) const
inlineconstexprnoexcept

Access the y element from the vector.

Returns
a reference to the y element.

◆ y() [2/2]

constexpr float & hi::v1::vector3::y ( )
inlineconstexprnoexcept

Access the y element from the vector.

Returns
a reference to the y element.

◆ z() [1/2]

constexpr float hi::v1::vector3::z ( ) const
inlineconstexprnoexcept

Access the z element from the vector.

Returns
a reference to the z element.

◆ z() [2/2]

constexpr float & hi::v1::vector3::z ( )
inlineconstexprnoexcept

Access the z element from the vector.

Returns
a reference to the z element.

Friends And Related Symbol Documentation

◆ ceil

constexpr vector3 ceil ( vector3 const & rhs)
friend

Round the elements of the vector toward upward and to the right.

◆ cross

constexpr friend vector3 cross ( vector3 const & lhs,
vector3 const & rhs )
friend

Get the cross product between two 3D vectors.

Parameters
lhsThe first vector.
rhsThe second vector.
Returns
A vector that is perpendicular to the given vectors.

◆ dot

constexpr friend float dot ( vector3 const & lhs,
vector3 const & rhs )
friend

Get the dot product between two vectors.

Parameters
lhsThe first vector.
rhsThe second vector.
Returns
The dot product from the two given vectors.

◆ floor

constexpr vector3 floor ( vector3 const & rhs)
friend

Round the elements of the vector toward downward and to the left.

◆ hypot

float hypot ( vector3 const & rhs)
friend

Get the length of the vector.

Parameters
rhsThe vector.
Returns
The length of the vector.

◆ max

constexpr vector3 max ( vector3 const & lhs,
vector3 const & rhs )
friend

Mix the two vectors and get the highest value of each element.

Parameters
lhsThe first vector.
rhsThe first vector.
Returns
A vector that points the most right of both vectors, and most upward of both vectors.

◆ min

constexpr vector3 min ( vector3 const & lhs,
vector3 const & rhs )
friend

Mix the two vectors and get the lowest value of each element.

Parameters
lhsThe first vector.
rhsThe first vector.
Returns
A vector that points the most left of both vectors, and most downward of both vectors.

◆ normal

constexpr friend vector3 normal ( vector3 const & rhs,
float angle )
friend

Get the normal on a 3D vector.

Parameters
rhsThe vector.
angleThe angle around the vector, only value_type{0} is implemented (xy-plane)
Returns
A normal on the vector.

◆ normalize

constexpr friend vector3 normalize ( vector3 const & rhs)
friend

Normalize a vector to a unit vector.

Parameters
rhsThe vector.
Returns
A vector with the same direction as the given vector, but its length is 1.0.

◆ operator* [1/2]

constexpr friend vector3 operator* ( float const & lhs,
vector3 const & rhs )
friend

Scale the vector by a scaler.

Parameters
lhsThe vector to scale.
rhsThe scaling factor.
Returns
The scaled vector.

◆ operator* [2/2]

constexpr friend vector3 operator* ( vector3 const & lhs,
float const & rhs )
friend

Scale the vector by a scaler.

Parameters
lhsThe vector to scale.
rhsThe scaling factor.
Returns
The scaled vector.

◆ operator+

constexpr friend vector3 operator+ ( vector3 const & lhs,
vector3 const & rhs )
friend

Add two vectors from each other.

Parameters
lhsThe first vector.
rhsThe second vector.
Returns
A new vector.

◆ operator-

constexpr friend vector3 operator- ( vector3 const & lhs,
vector3 const & rhs )
friend

Subtract two vectors from each other.

Parameters
lhsThe first vector.
rhsThe second vector.
Returns
A new vector.

◆ operator==

constexpr friend bool operator== ( vector3 const & lhs,
vector3 const & rhs )
friend

Compare if two vectors are equal.

Parameters
lhsThe first vector.
rhsThe second vector.
Returns
True if both vectors are completely equal to each other.

◆ rcp_hypot

constexpr friend float rcp_hypot ( vector3 const & rhs)
friend

Get the length of the vector.

Parameters
rhsThe vector.
Returns
One over the length of the vector.

◆ round

constexpr vector3 round ( vector3 const & rhs)
friend

Round the elements of the vector toward nearest integer.

◆ squared_hypot

constexpr friend float squared_hypot ( vector3 const & rhs)
friend

Get the squared length of the vector.

Parameters
rhsThe vector.
Returns
The length of the vector.

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