Glade Reference


Vector class

A Vector class represents a direction.

 

Vector::Vector

Creates a Vector object v. The Vector is initialised to (0.0, 0.0) by default.

Vector::Vector(double x, double y)

Creates a Vector v, initialised with the values x and y.

Vector::Vector(int x1, int x2, int y1, int y2)

Creates a Vector v, initialised with the difference between x1 and x2, and the difference between y1 and y2.

 

Vector::setX(int x)

Set the Vector X value.

 

Vector::setY(int y)

Set the Vector Y value.

 

double Vector::x

Get the X component of the Vector v.

 

double Vector::y

Get the Y component of the Vector v.

 

Vector::operator +

Adds the two Vectors.

 

Vector::operator -

Subtracts the two Vectors.

 

Vector::operator *

Returns a Vector multiplied by a scalar.

 

Vector::operator /

Returns a Vector divided by a scalar.

Vector::dotProduct(const Vector &other) const

Returns the dot product of the vector with the other vector.

Vector::crossProduct(const Vector &other) const

Returns the cross product of the vector with the other vector.

Vector::length() const

Returns the length of the vector.

Vector::unit() const

Returns the unit vector, i.e. its components divided by the vector length.

Vector::normal() const

Returns the normal vector, i.e. a vector perpendicular to this vector.

dot(u, v)

A macro returning the dot product of the two vectors u and v. Being a macro u and v can be any numeric type.

cross(u, v)

A macro returning the cross product of the two vectors u and v. Being a macro u and v can be any numeric type.

norm(u)

A macro returning the length of the vector u. Being a macro u can be any numeric type.

dist(u, v)

A macro returning the norm of the difference of the vectors u and v. Being a macro u and v can be any numeric type.

 

 

Contents|Index

Copyright © Peardrop Design 2024.