QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 *
11  * it under the terms of the GNU General Public License as published by *
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 }
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values.
Definition: Vector3D.h:36
bool operator!=(const Vector3D &v) const
Definition: Vector3D.cpp:37
void standardise()
Standardises the vector.
Definition: Vector3D.cpp:24
double mX
X-component of the vector.
Definition: Vector3D.h:39
void setX(double x)
Sets the x-component of the vector.
Definition: Vector3D.h:105
bool operator==(const Vector3D &v) const
Definition: Vector3D.cpp:32
double getY() const
Returns the y-component of the vector.
Definition: Vector3D.h:95
double mZ
Z-component of the vector.
Definition: Vector3D.h:43
double getX() const
Returns the x-component of the vector.
Definition: Vector3D.h:90
void setY(double y)
Sets the y-component of the vector.
Definition: Vector3D.h:110
double getZ() const
Returns the z-component of the vector.
Definition: Vector3D.h:100
double getLength() const
Returns the length of the vector.
Definition: Vector3D.cpp:19
double mY
Y-component of the vector.
Definition: Vector3D.h:41
void setZ(double z)
Sets the z-component of the vector.
Definition: Vector3D.h:115