O --- O
libPEDSIM Documentation
[HOME] [EXAMPLES] [ECOSYSTEM] [DOCUMENTATION] [DOWNLOAD]
O --- O
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Ped::Tvector Class Reference

#include <ped_vector.h>

Public Member Functions

 Tvector ()
 
 Tvector (double px, double py, double pz=0)
 
double length () const
 
double lengthSquared () const
 
void normalize ()
 
Tvector normalized () const
 
void scale (double factor)
 
Tvector scaled (double factor) const
 
Tvector leftNormalVector () const
 
Tvector rightNormalVector () const
 
double polarRadius () const
 
double polarAngle () const
 
double angleTo (const Tvector &other) const
 
void rotate (double theta)
 
Ped::Tvector rotated (double theta) const
 
std::string to_string () const
 
Tvector operator+ (const Tvector &other) const
 
Tvector operator- (const Tvector &other) const
 
Tvector operator* (double factor) const
 
Tvector operator/ (double divisor) const
 
Tvectoroperator+= (const Tvector &vectorIn)
 
Tvectoroperator-= (const Tvector &vectorIn)
 
Tvectoroperator*= (double factor)
 
Tvectoroperator*= (const Tvector &vectorIn)
 
Tvectoroperator/= (double divisor)
 

Static Public Member Functions

static double scalar (const Tvector &a, const Tvector &b)
 
static double dotProduct (const Tvector &a, const Tvector &b)
 
static Tvector crossProduct (const Tvector &a, const Tvector &b)
 
static bool lineIntersection (const Ped::Tvector &p0, const Ped::Tvector &p1, const Ped::Tvector &p2, const Ped::Tvector &p3, Ped::Tvector *intersection)
 

Public Attributes

double x
 
double y
 
double z
 

Detailed Description

Vector helper class. This is basically a struct with some related functions attached. x, y, and z are public, so that they can be accessed easily.

Examples:
examples/example02.cpp, and examples/example03.cpp.

Definition at line 32 of file ped_vector.h.

Constructor & Destructor Documentation

Ped::Tvector::Tvector ( )

Default constructor, which makes sure that all the values are set to 0.

Date
2012-01-16

Definition at line 18 of file ped_vector.cpp.

Member Function Documentation

Ped::Tvector Ped::Tvector::crossProduct ( const Tvector a,
const Tvector b 
)
static

Calculates the cross product of two vectors.

Date
2010-02-12
Parameters
&aThe first vector
&bThe second vector

Definition at line 91 of file ped_vector.cpp.

double Ped::Tvector::dotProduct ( const Tvector a,
const Tvector b 
)
static

Vector dot product helper: calculates the dot product of two vectors.

Date
2012-01-14
Returns
The dot product.
Parameters
&aThe first vector
&bThe second vector

Definition at line 82 of file ped_vector.cpp.

Referenced by Ped::Twaypoint::normalpoint(), and scalar().

double Ped::Tvector::length ( ) const

Returns the length of the vector.

Returns
the length
Examples:
examples/example03.cpp.

Definition at line 28 of file ped_vector.cpp.

Referenced by Ped::Twaypoint::getForce(), scalar(), and Ped::Tagent::socialForce().

double Ped::Tvector::lengthSquared ( ) const

Returns the length of the vector squared. This is faster than the real length.

Returns
the length squared

Definition at line 36 of file ped_vector.cpp.

Referenced by Ped::Twaypoint::normalpoint(), Ped::Tagent::obstacleForce(), and Ped::Tagent::socialForce().

bool Ped::Tvector::lineIntersection ( const Ped::Tvector p0,
const Ped::Tvector p1,
const Ped::Tvector p2,
const Ped::Tvector p3,
Ped::Tvector intersection 
)
static

Calculates the itnersection point of two lines, defined by Ped::Tvectors p0, p1, and p2, p3 respectively. Based on an algorithm in Andre LeMothe's "Tricks of the Windows Game Programming Gurus"

Returns
bool True if there is an intersection, false otherwise
*intersection If the supplied pointer to a Ped::Tvector is not NULL, it will contain the intersection point, if there is an intersection.
Examples:
examples/example03.cpp.

Definition at line 264 of file ped_vector.cpp.

Referenced by Ped::Tagent::move().

void Ped::Tvector::normalize ( )

Normalizes the vector to a length of 1.

Date
2010-02-12

Definition at line 43 of file ped_vector.cpp.

Ped::Tvector Ped::Tvector::normalized ( ) const

Normalizes the vector to a length of 1.

Date
2013-08-02
Examples:
examples/example03.cpp.

Definition at line 57 of file ped_vector.cpp.

Referenced by Ped::Tagent::desiredForce(), Ped::Twaypoint::getForce(), Ped::Tagent::move(), Ped::Tagent::obstacleForce(), and Ped::Tagent::socialForce().

void Ped::Tvector::rotate ( double  theta)

Rotates a vector. Rotates around 0,0 in 2 dimensions only (z unchanged)v

Parameters
thetain rad

Definition at line 285 of file ped_vector.cpp.

Ped::Tvector Ped::Tvector::rotated ( double  theta) const

Rotates a vector. Rotates around 0,0 in 2 dimensions only (z set to 0.0)

Parameters
thetain rad
Examples:
examples/example03.cpp.

Definition at line 294 of file ped_vector.cpp.

double Ped::Tvector::scalar ( const Tvector a,
const Tvector b 
)
static

Vector scalar product helper: calculates the scalar product of two vectors.

Date
2012-01-14
Returns
The scalar product.
Parameters
&aThe first vector
&bThe second vector

Definition at line 72 of file ped_vector.cpp.

void Ped::Tvector::scale ( double  factor)

Scales this vector by a given factor in each dimension.

Date
2013-08-02
Parameters
factorThe scalar value to multiply with.

Definition at line 102 of file ped_vector.cpp.

Ped::Tvector Ped::Tvector::scaled ( double  factor) const

Returns a copy of this vector which is multiplied in each dimension by a given factor.

Date
2013-07-16
Returns
The scaled vector.
Parameters
factorThe scalar value to multiply with.
Examples:
examples/example03.cpp.

Definition at line 113 of file ped_vector.cpp.


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

⁠(c) Christian Gloor [ c|h|g|l|o|o|r|@|s|i|l|m|a|r|i|l|.|o|r|g| ]