KiCad PCB EDA Suite
SGVECTOR Class Reference

#include <sg_base.h>

Public Member Functions

 SGVECTOR ()
 
 SGVECTOR (double aXVal, double aYVal, double aZVal)
 
void GetVector (double &aXVal, double &aYVal, double &aZVal) const noexcept
 
void SetVector (double aXVal, double aYVal, double aZVal)
 
void SetVector (const SGVECTOR &aVector)
 
SGVECTORoperator= (const SGVECTOR &source) noexcept
 

Private Member Functions

void normalize (void) noexcept
 

Private Attributes

double vx
 
double vy
 
double vz
 

Detailed Description

Definition at line 87 of file sg_base.h.

Constructor & Destructor Documentation

◆ SGVECTOR() [1/2]

SGVECTOR::SGVECTOR ( )

Definition at line 208 of file sg_base.cpp.

209 {
210  vx = 0.0;
211  vy = 0.0;
212  vz = 1.0;
213 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93

References vx, vy, and vz.

◆ SGVECTOR() [2/2]

SGVECTOR::SGVECTOR ( double  aXVal,
double  aYVal,
double  aZVal 
)

Definition at line 216 of file sg_base.cpp.

217 {
218  vx = aXVal;
219  vy = aYVal;
220  vz = aZVal;
221  normalize();
222 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
void normalize(void) noexcept
Definition: sg_base.cpp:248

References normalize(), vx, vy, and vz.

Member Function Documentation

◆ GetVector()

void SGVECTOR::GetVector ( double &  aXVal,
double &  aYVal,
double &  aZVal 
) const
noexcept

Definition at line 225 of file sg_base.cpp.

226 {
227  aXVal = vx;
228  aYVal = vy;
229  aZVal = vz;
230 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93

Referenced by S3D::FormatOrientation(), S3D::FormatVector(), SGSHAPE::Prepare(), SCENEGRAPH::Prepare(), SetVector(), and S3D::WriteVector().

◆ normalize()

void SGVECTOR::normalize ( void  )
privatenoexcept

Definition at line 248 of file sg_base.cpp.

249 {
250  double dx = vx * vx;
251  double dy = vy * vy;
252  double dz = vz * vz;
253  double dv2 = sqrt( dx + dy + dz );
254 
255  if( ( dx + dy + dz ) < 1e-8 )
256  {
257  // use the default; the numbers are too small to be believable
258  vx = 0.0;
259  vy = 0.0;
260  vz = 1.0;
261  return;
262  }
263 
264  vx /= dv2;
265  vy /= dv2;
266  vz /= dv2;
267 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93

Referenced by SetVector(), and SGVECTOR().

◆ operator=()

SGVECTOR & SGVECTOR::operator= ( const SGVECTOR source)
noexcept

Definition at line 270 of file sg_base.cpp.

271 {
272  vx = source.vx;
273  vy = source.vy;
274  vz = source.vz;
275  return *this;
276 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93

References vx.

◆ SetVector() [1/2]

void SGVECTOR::SetVector ( double  aXVal,
double  aYVal,
double  aZVal 
)

Definition at line 233 of file sg_base.cpp.

234 {
235  vx = aXVal;
236  vy = aYVal;
237  vz = aZVal;
238  normalize();
239 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
void normalize(void) noexcept
Definition: sg_base.cpp:248

References normalize(), vx, vy, and vz.

Referenced by EXPORTER_PCB_VRML::create_vrml_shell(), S3D::ReadVector(), and vrmlToSG().

◆ SetVector() [2/2]

void SGVECTOR::SetVector ( const SGVECTOR aVector)

Definition at line 242 of file sg_base.cpp.

243 {
244  aVector.GetVector( vx, vy, vz );
245 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
void GetVector(double &aXVal, double &aYVal, double &aZVal) const noexcept
Definition: sg_base.cpp:225

References GetVector(), vx, vy, and vz.

Member Data Documentation

◆ vx

double SGVECTOR::vx
private

Definition at line 92 of file sg_base.h.

Referenced by operator=(), SetVector(), and SGVECTOR().

◆ vy

double SGVECTOR::vy
private

Definition at line 93 of file sg_base.h.

Referenced by SetVector(), and SGVECTOR().

◆ vz

double SGVECTOR::vz
private

Definition at line 94 of file sg_base.h.

Referenced by SetVector(), and SGVECTOR().


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