QGIS API Documentation  3.14.0-Pi (9f7028fd23)
Vector3D.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  Vector3D.cpp
3  ------------
4  copyright : (C) 2004 by Marco Hugentobler
5  email : [email protected]
6  ***************************************************************************/
7
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16
17 #include "Vector3D.h"
18
19 double Vector3D::getLength() const
20 {
21  return sqrt( getX() * getX() + getY() * getY() + getZ() * getZ() );
22 }
23
25 {
26  double length = getLength();
27  setX( getX() / length );
28  setY( getY() / length );
29  setZ( getZ() / length );
30 }
31
32 bool Vector3D::operator==( const Vector3D &v ) const
33 {
34  return ( mX == v.getX() && mY == v.getY() && mZ == v.getZ() );
35 }
36
37 bool Vector3D::operator!=( const Vector3D &v ) const
38 {
39  return ( !( ( *this ) == v ) );
40 }
Vector3D::setX
void setX(double x)
Sets the x-component of the vector.
Definition: Vector3D.h:103
Vector3D::getLength
double getLength() const
Returns the length of the vector.
Definition: Vector3D.cpp:19
Vector3D::mX
double mX
X-component of the vector.
Definition: Vector3D.h:37
Vector3D::standardise
void standardise()
Standardises the vector.
Definition: Vector3D.cpp:24
Vector3D::getZ
double getZ() const
Returns the z-component of the vector.
Definition: Vector3D.h:98
Vector3D::mY
double mY
Y-component of the vector.
Definition: Vector3D.h:39
Vector3D::getY
double getY() const
Returns the y-component of the vector.
Definition: Vector3D.h:93
Vector3D::mZ
double mZ
Z-component of the vector.
Definition: Vector3D.h:41
Vector3D::setY
void setY(double y)
Sets the y-component of the vector.
Definition: Vector3D.h:108
Vector3D::setZ
void setZ(double z)
Sets the z-component of the vector.
Definition: Vector3D.h:113
Vector3D::operator!=
bool operator!=(const Vector3D &v) const
Definition: Vector3D.cpp:37
Vector3D
Definition: Vector3D.h:33
Vector3D.h
Vector3D::getX
double getX() const
Returns the x-component of the vector.
Definition: Vector3D.h:88
Vector3D::operator==
bool operator==(const Vector3D &v) const
Definition: Vector3D.cpp:32