Prusa MINI Firmware overview
vector_3 Struct Reference

#include <vector_3.h>

Inheritance diagram for vector_3:
Collaboration diagram for vector_3:

Public Member Functions

 vector_3 (const float &_x, const float &_y, const float &_z)
 
 vector_3 (const xy_float_t &in)
 
 vector_3 (const xyz_float_t &in)
 
 vector_3 (const xyze_float_t &in)
 
void normalize ()
 
void apply_rotation (const matrix_3x3 &matrix)
 
float get_length () const
 
vector_3 get_normal () const
 
FORCE_INLINE vector_3 operator+ (const vector_3 &v) const
 
FORCE_INLINE vector_3 operator- (const vector_3 &v) const
 
FORCE_INLINE vector_3 operator* (const float &v) const
 
void debug (PGM_P const title)
 
- Public Member Functions inherited from XYZval< float >
FI void set (const float px)
 
FI void set (const float px, const float py)
 
FI void set (const float px, const float py, const float pz)
 
FI void set (const XYval< float > pxy, const float pz)
 
FI void reset ()
 
FI float magnitude () const
 
FI operator float * ()
 
FI operator bool ()
 
FI XYZval< float > copy () const
 
FI XYZval< float > ABS () const
 
FI XYZval< int16_t > asInt ()
 
FI XYZval< int16_t > asInt () const
 
FI XYZval< int32_t > asLong ()
 
FI XYZval< int32_t > asLong () const
 
FI XYZval< float > asFloat ()
 
FI XYZval< float > asFloat () const
 
FI XYZval< float > reciprocal () const
 
FI XYZval< float > asLogical () const
 
FI XYZval< float > asNative () const
 
FI operator XYval< float > & ()
 
FI operator const XYval< float > & () const
 
FI operator XYZEval< float > () const
 
FI float & operator[] (const int i)
 
const FI float & operator[] (const int i) const
 
FI XYZval< float > & operator= (const float v)
 
FI XYZval< float > & operator= (const XYval< float > &rs)
 
FI XYZval< float > & operator= (const XYZEval< float > &rs)
 
FI XYZval< float > operator+ (const XYval< float > &rs) const
 
FI XYZval< float > operator+ (const XYval< float > &rs)
 
FI XYZval< float > operator+ (const XYZval< float > &rs) const
 
FI XYZval< float > operator+ (const XYZval< float > &rs)
 
FI XYZval< float > operator+ (const XYZEval< float > &rs) const
 
FI XYZval< float > operator+ (const XYZEval< float > &rs)
 
FI XYZval< float > operator- (const XYval< float > &rs) const
 
FI XYZval< float > operator- (const XYval< float > &rs)
 
FI XYZval< float > operator- (const XYZval< float > &rs) const
 
FI XYZval< float > operator- (const XYZval< float > &rs)
 
FI XYZval< float > operator- (const XYZEval< float > &rs) const
 
FI XYZval< float > operator- (const XYZEval< float > &rs)
 
FI XYZval< float > operator- ()
 
const FI XYZval< float > operator- () const
 
FI XYZval< float > operator* (const XYval< float > &rs) const
 
FI XYZval< float > operator* (const XYval< float > &rs)
 
FI XYZval< float > operator* (const XYZval< float > &rs) const
 
FI XYZval< float > operator* (const XYZval< float > &rs)
 
FI XYZval< float > operator* (const XYZEval< float > &rs) const
 
FI XYZval< float > operator* (const XYZEval< float > &rs)
 
FI XYZval< float > operator* (const float &v) const
 
FI XYZval< float > operator* (const float &v)
 
FI XYZval< float > operator* (const int &v) const
 
FI XYZval< float > operator* (const int &v)
 
FI XYZval< float > operator/ (const XYval< float > &rs) const
 
FI XYZval< float > operator/ (const XYval< float > &rs)
 
FI XYZval< float > operator/ (const XYZval< float > &rs) const
 
FI XYZval< float > operator/ (const XYZval< float > &rs)
 
FI XYZval< float > operator/ (const XYZEval< float > &rs) const
 
FI XYZval< float > operator/ (const XYZEval< float > &rs)
 
FI XYZval< float > operator/ (const float &v) const
 
FI XYZval< float > operator/ (const float &v)
 
FI XYZval< float > operator/ (const int &v) const
 
FI XYZval< float > operator/ (const int &v)
 
FI XYZval< float > operator>> (const int &v) const
 
FI XYZval< float > operator>> (const int &v)
 
FI XYZval< float > operator<< (const int &v) const
 
FI XYZval< float > operator<< (const int &v)
 
FI XYZval< float > & operator+= (const XYval< float > &rs)
 
FI XYZval< float > & operator+= (const XYZval< float > &rs)
 
FI XYZval< float > & operator+= (const XYZEval< float > &rs)
 
FI XYZval< float > & operator-= (const XYval< float > &rs)
 
FI XYZval< float > & operator-= (const XYZval< float > &rs)
 
FI XYZval< float > & operator-= (const XYZEval< float > &rs)
 
FI XYZval< float > & operator*= (const XYval< float > &rs)
 
FI XYZval< float > & operator*= (const XYZval< float > &rs)
 
FI XYZval< float > & operator*= (const XYZEval< float > &rs)
 
FI XYZval< float > & operator*= (const float &v)
 
FI XYZval< float > & operator*= (const int &v)
 
FI XYZval< float > & operator/= (const XYval< float > &rs)
 
FI XYZval< float > & operator/= (const XYZval< float > &rs)
 
FI XYZval< float > & operator/= (const XYZEval< float > &rs)
 
FI XYZval< float > & operator>>= (const int &v)
 
FI XYZval< float > & operator<<= (const int &v)
 
FI bool operator== (const XYZEval< float > &rs)
 
FI bool operator== (const XYZEval< float > &rs) const
 
FI bool operator!= (const XYZEval< float > &rs)
 
FI bool operator!= (const XYZEval< float > &rs) const
 

Static Public Member Functions

static vector_3 cross (const vector_3 &a, const vector_3 &b)
 

Additional Inherited Members

- Public Attributes inherited from XYZval< float >
float x
 
float y
 
float z
 
float a
 
float b
 
float c
 
float pos [3]
 
union {
   struct {
      T   x
 
      T   y
 
      T   z
 
   } 
 
   struct {
      T   a
 
      T   b
 
      T   c
 
   } 
 
   T   pos [3]
 
}; 
 

Constructor & Destructor Documentation

◆ vector_3() [1/4]

vector_3::vector_3 ( const float &  _x,
const float &  _y,
const float &  _z 
)
49 { set(_x, _y, _z); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_3() [2/4]

vector_3::vector_3 ( const xy_float_t in)
50 { set(in.x, in.y); }
Here is the call graph for this function:

◆ vector_3() [3/4]

vector_3::vector_3 ( const xyz_float_t in)
51 { set(in.x, in.y, in.z); }
Here is the call graph for this function:

◆ vector_3() [4/4]

vector_3::vector_3 ( const xyze_float_t in)
52 { set(in.x, in.y, in.z); }
Here is the call graph for this function:

Member Function Documentation

◆ cross()

vector_3 vector_3::cross ( const vector_3 left,
const vector_3 right 
)
static

Marlin 3D Printer Firmware Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]

Based on Sprinter and grbl. Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. vector_3.cpp - Vector library for bed leveling Copyright (c) 2012 Lars Brubaker. All right reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA vector_3

54  {
55  const xyz_float_t &lv = left, &rv = right;
56  return vector_3(lv.y * rv.z - lv.z * rv.y, // YZ cross
57  lv.z * rv.x - lv.x * rv.z, // ZX cross
58  lv.x * rv.y - lv.y * rv.x); // XY cross
59 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize()

void vector_3::normalize ( )
67  {
68  *this *= RSQRT(sq(x) + sq(y) + sq(z));
69 }
Here is the caller graph for this function:

◆ apply_rotation()

void vector_3::apply_rotation ( const matrix_3x3 matrix)
72  {
73  const float _x = x, _y = y, _z = z;
74  *this = matrix.vectors[0] * _x + matrix.vectors[1] * _y + matrix.vectors[2] * _z;
75 }
Here is the caller graph for this function:

◆ get_length()

float vector_3::get_length ( ) const

◆ get_normal()

vector_3 vector_3::get_normal ( ) const
61  {
62  vector_3 normalized = *this;
63  normalized.normalize();
64  return normalized;
65 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator+()

FORCE_INLINE vector_3 vector_3::operator+ ( const vector_3 v) const
66 { vector_3 o = *this; o += v; return o; }

◆ operator-()

FORCE_INLINE vector_3 vector_3::operator- ( const vector_3 v) const
67 { vector_3 o = *this; o -= v; return o; }

◆ operator*()

FORCE_INLINE vector_3 vector_3::operator* ( const float &  v) const
68 { vector_3 o = *this; o *= v; return o; }

◆ debug()

void vector_3::debug ( PGM_P const  title)
77  {
78  serialprintPGM(title);
79  SERIAL_ECHOPAIR_F(" X", x, 6);
80  SERIAL_ECHOPAIR_F(" Y", y, 6);
81  SERIAL_ECHOLNPAIR_F(" Z", z, 6);
82 }
Here is the call graph for this function:
XYZval::z
T z
Definition: types.h:286
vector_3::normalize
void normalize()
Definition: vector_3.cpp:67
RSQRT
#define RSQRT(x)
Definition: macros.h:282
sq
#define sq(x)
Definition: wiring_constants.h:83
XYZEval::z
T z
Definition: types.h:383
XYZval::x
T x
Definition: types.h:286
SERIAL_ECHOLNPAIR_F
#define SERIAL_ECHOLNPAIR_F(V...)
Definition: serial.h:177
XYZval< float >::set
FI void set(const float px)
Definition: types.h:290
vector_3::vector_3
vector_3(const float &_x, const float &_y, const float &_z)
Definition: vector_3.h:49
XYZEval::x
T x
Definition: types.h:383
matrix_3x3::vectors
abc_float_t vectors[3]
Definition: vector_3.h:74
XYval::x
T x
Definition: types.h:185
XYZval::y
T y
Definition: types.h:286
SERIAL_ECHOPAIR_F
#define SERIAL_ECHOPAIR_F(S, V...)
Definition: serial.h:176
vector_3
Definition: vector_3.h:47
XYval::y
T y
Definition: types.h:185
XYZval
Definition: types.h:100
serialprintPGM
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35
XYZEval::y
T y
Definition: types.h:383