RoboDK Plug-In Interface
Loading...
Searching...
No Matches
Vector3 Class Reference

The Vector3 class represents a vector or vertex in 3D space. More...

#include <vector3.h>

Public Member Functions

 Vector3 ()=default
 Constructs a null vector, i.e.
 
 Vector3 (double x, double y, double z)
 Constructs a vector with coordinates (x, y, z).
 
 Vector3 (const Vector3 &v)=default
 Constructs a vector object as a copy of v.
 
double Length () const
 Returns the length of the vector from the origin.
 
void Normalize ()
 Normalizes the currect vector in place.
 
double X () const
 Returns the x coordinate of this vector.
 
double Y () const
 Returns the y coordinate of this vector.
 
double Z () const
 Returns the z coordinate of this vector.
 
void SetX (double x)
 Sets the x coordinate of this vector to the given x coordinate.
 
void SetY (double y)
 Sets the y coordinate of this vector to the given y coordinate.
 
void SetZ (double z)
 Sets the z coordinate of this vector to the given z coordinate.
 
const double & operator[] (size_t i) const
 Returns the component of the vector at index position i.
 
double & operator[] (size_t i)
 Returns the component of the vector at index position i as a modifiable reference.
 
Vector3operator= (const Vector3 &v)=default
 Sets this Vector3 object as a copy of v.
 

Static Public Member Functions

static double DotProduct (const Vector3 &v1, const Vector3 &v2)
 Returns the dot product of v1 and v2.
 
static Vector3 CrossProduct (const Vector3 &v1, const Vector3 &v2)
 Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2.
 

Detailed Description

The Vector3 class represents a vector or vertex in 3D space.

Vectors are one of the main building blocks of 3D representation and drawing. They consist of three coordinates, traditionally called x, y, and z.

Definition at line 48 of file vector3.h.

Constructor & Destructor Documentation

◆ Vector3() [1/2]

Vector3 ( )
default

Constructs a null vector, i.e.

with coordinates (0, 0, 0).

◆ Vector3() [2/2]

Vector3 ( double x,
double y,
double z )

Constructs a vector with coordinates (x, y, z).

Definition at line 38 of file vector3.cpp.

Member Function Documentation

◆ CrossProduct()

Vector3 CrossProduct ( const Vector3 & v1,
const Vector3 & v2 )
static

Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2.

Definition at line 66 of file vector3.cpp.

◆ DotProduct()

double DotProduct ( const Vector3 & v1,
const Vector3 & v2 )
static

Returns the dot product of v1 and v2.

Definition at line 61 of file vector3.cpp.

◆ Length()

double Length ( ) const

Returns the length of the vector from the origin.

Definition at line 45 of file vector3.cpp.

◆ Normalize()

void Normalize ( )

Normalizes the currect vector in place.

Nothing happens if this vector is a null vector or the length of the vector is very close to 1.

Definition at line 50 of file vector3.cpp.

◆ operator[]() [1/2]

double & operator[] ( size_t i)
inline

Returns the component of the vector at index position i as a modifiable reference.

Definition at line 116 of file vector3.h.

◆ operator[]() [2/2]

const double & operator[] ( size_t i) const
inline

Returns the component of the vector at index position i.

Definition at line 110 of file vector3.h.

◆ SetX()

void SetX ( double x)
inline

Sets the x coordinate of this vector to the given x coordinate.

Definition at line 95 of file vector3.h.

◆ SetY()

void SetY ( double y)
inline

Sets the y coordinate of this vector to the given y coordinate.

Definition at line 100 of file vector3.h.

◆ SetZ()

void SetZ ( double z)
inline

Sets the z coordinate of this vector to the given z coordinate.

Definition at line 105 of file vector3.h.

◆ X()

double X ( ) const
inline

Returns the x coordinate of this vector.

Definition at line 80 of file vector3.h.

◆ Y()

double Y ( ) const
inline

Returns the y coordinate of this vector.

Definition at line 85 of file vector3.h.

◆ Z()

double Z ( ) const
inline

Returns the z coordinate of this vector.

Definition at line 90 of file vector3.h.


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