QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Vector3D.cpp
Go to the documentation of this file.
1/***************************************************************************
2 Vector3D.cpp
3 ------------
4 copyright : (C) 2004 by Marco Hugentobler
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
19double Vector3D::getLength() const
20{
21 return sqrt( getX() * getX() + getY() * getY() + getZ() * getZ() );
22}
23
25{
26 const double length = getLength();
27 setX( getX() / length );
28 setY( getY() / length );
29 setZ( getZ() / length );
30}
31
32bool Vector3D::operator==( const Vector3D &v ) const
33{
34 return ( mX == v.getX() && mY == v.getY() && mZ == v.getZ() );
35}
36
37bool 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:106
bool operator==(const Vector3D &v) const
Definition: Vector3D.cpp:32
double getY() const
Returns the y-component of the vector.
Definition: Vector3D.h:96
double mZ
Z-component of the vector.
Definition: Vector3D.h:43
double getX() const
Returns the x-component of the vector.
Definition: Vector3D.h:91
void setY(double y)
Sets the y-component of the vector.
Definition: Vector3D.h:111
double getZ() const
Returns the z-component of the vector.
Definition: Vector3D.h:101
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:116