14 namespace SpatialStructures {
22 Node::Node(
float x,
float y,
float z,
int id) : x(x), y(y), z(z), id(id) {};
42 sqrtf(pow((
x - n2.
x), 2) +
63 throw std::exception();
79 throw std::exception();
84 const float dist = sqrtf(powf(n2.
x -
x, 2) + powf(n2.
y -
y, 2) + powf(n2.
z -
z, 2));
124 auto magnitude = sqrtf(powf(vector[0], 2) + powf(vector[1], 2) + powf(vector[2], 2));
125 vector[0] = vector[0] / magnitude;
126 vector[1] = vector[1] / magnitude;
127 vector[2] = vector[2] / magnitude;
132 std::array<float, 3> direction_vector;
133 direction_vector[0] = n2.
x -
x;
134 direction_vector[1] = n2.
y -
y;
135 direction_vector[2] = n2.
z -
z;
138 return direction_vector;
142 return std::array<float, 3>{
x,
y,
z};
Contains definitions for the HF::SpatialStructures namespace.
Contains definitions for the Node structure.
Perform human scale analysis on 3D environments.
constexpr float ROUNDING_PRECISION
Minimum value that can be represented in DHART_API.
NODE_TYPE
The type of node this is.
@ GRAPH
This node is a graph node.
void Normalize(std::array< float, 3 > &vector)
A point in space with an ID.
Node operator+(const Node &n2) const
Creates a new node from the vector addition of this node and n2.
Node operator*(const Node &n2) const
Creates a new node from the dot product of this node and n2.
bool operator<(const Node &n2) const
Determines if this node's id (an integer) is less than n2's id.
Node()
Default constructor. Every element contained is defaulted to NAN.
float z
Cartesian coordinates x, y, z.
std::array< float, 3 > getArray() const
Returns the x,y,z of this node as an array of 3 floats.
float & operator[](int i)
Directly access a nodes's position as if it were an array of 3 floats,
bool operator!=(const Node &n2) const
See operator==, checks if this node does NOT occupy the same space as n2.
bool operator>(const Node &n2) const
Determines if this node's id (an integer) is greater than n2's id
float distanceTo(const Node &n2) const
Calculate the distance between this node and n2.
std::array< float, 3 > directionTo(const Node &n2) const
Get the direction between this node and another node
Node operator-(const Node &n2) const
Creates a node from the vector subtraction of this node and n2's position.
bool operator==(const Node &n2) const
Check if this node occupies the same space as n2.