QGIS API Documentation  3.6.0-Noosa (5873452)
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 }
void setX(double x)
Sets the x-component of the vector.
Definition: Vector3D.h:103
double getLength() const
Returns the length of the vector.
Definition: Vector3D.cpp:19
void standardise()
Standardises the vector.
Definition: Vector3D.cpp:24
double getZ() const
Returns the z-component of the vector.
Definition: Vector3D.h:98
Class Vector3D represents a 3D-Vector, capable to store x-,y- and z-coordinates in double values...
Definition: Vector3D.h:33
void setZ(double z)
Sets the z-component of the vector.
Definition: Vector3D.h:113
double mX
X-component of the vector.
Definition: Vector3D.h:37
double mZ
Z-component of the vector.
Definition: Vector3D.h:41
double getY() const
Returns the y-component of the vector.
Definition: Vector3D.h:93
double mY
Y-component of the vector.
Definition: Vector3D.h:39
void setY(double y)
Sets the y-component of the vector.
Definition: Vector3D.h:108
bool operator!=(const Vector3D &v) const
Definition: Vector3D.cpp:37
double getX() const
Returns the x-component of the vector.
Definition: Vector3D.h:88
bool operator==(const Vector3D &v) const
Definition: Vector3D.cpp:32