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
 
void SetVector (double aXVal, double aYVal, double aZVal)
 
void SetVector (const SGVECTOR &aVector)
 
SGVECTORoperator= (const SGVECTOR &source)
 

Private Member Functions

void normalize (void)
 

Private Attributes

double vx
 
double vy
 
double vz
 

Detailed Description

Definition at line 87 of file sg_base.h.

Constructor & Destructor Documentation

SGVECTOR::SGVECTOR ( )

Definition at line 264 of file sg_base.cpp.

References vx, vy, and vz.

265 {
266  vx = 0.0;
267  vy = 0.0;
268  vz = 1.0;
269  return;
270 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
SGVECTOR::SGVECTOR ( double  aXVal,
double  aYVal,
double  aZVal 
)

Definition at line 273 of file sg_base.cpp.

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

274 {
275  vx = aXVal;
276  vy = aYVal;
277  vz = aZVal;
278  normalize();
279  return;
280 }
double vz
Definition: sg_base.h:94
void normalize(void)
Definition: sg_base.cpp:309
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93

Member Function Documentation

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

Definition at line 283 of file sg_base.cpp.

References vx, vy, and vz.

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

284 {
285  aXVal = vx;
286  aYVal = vy;
287  aZVal = vz;
288  return;
289 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
void SGVECTOR::normalize ( void  )
private

Definition at line 309 of file sg_base.cpp.

References vx, vy, and vz.

Referenced by SetVector(), and SGVECTOR().

310 {
311  double dx = vx * vx;
312  double dy = vy * vy;
313  double dz = vz * vz;
314  double dv2 = sqrt( dx + dy + dz );
315 
316  if( (dx + dy + dz) < 1e-8 )
317  {
318  // use the default; the numbers are too small
319  // to be believable
320  vx = 0.0;
321  vy = 0.0;
322  vz = 1.0;
323  return;
324  }
325 
326  vx /= dv2;
327  vy /= dv2;
328  vz /= dv2;
329 
330  return;
331 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
SGVECTOR & SGVECTOR::operator= ( const SGVECTOR source)

Definition at line 334 of file sg_base.cpp.

References vx, vy, and vz.

335 {
336  vx = source.vx;
337  vy = source.vy;
338  vz = source.vz;
339  return *this;
340 }
double vz
Definition: sg_base.h:94
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
void SGVECTOR::SetVector ( double  aXVal,
double  aYVal,
double  aZVal 
)

Definition at line 292 of file sg_base.cpp.

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

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

293 {
294  vx = aXVal;
295  vy = aYVal;
296  vz = aZVal;
297  normalize();
298  return;
299 }
double vz
Definition: sg_base.h:94
void normalize(void)
Definition: sg_base.cpp:309
double vx
Definition: sg_base.h:92
double vy
Definition: sg_base.h:93
void SGVECTOR::SetVector ( const SGVECTOR aVector)

Definition at line 302 of file sg_base.cpp.

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

303 {
304  aVector.GetVector( vx, vy, vz );
305  return;
306 }
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
Definition: sg_base.cpp:283

Member Data Documentation

double SGVECTOR::vx
private

Definition at line 92 of file sg_base.h.

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

double SGVECTOR::vy
private

Definition at line 93 of file sg_base.h.

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

double SGVECTOR::vz
private

Definition at line 94 of file sg_base.h.

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


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