2d direction vector
More...
#include <angelcad.h>
2d direction vector
vec2d is a 2-dimensional vector offering useful operations such as dot and cross products.
◆ vec2d() [1/3]
Create direction vector from p1 to p2.
- Parameters
-
p1 | pos2d@, vector start position
|
p2 | pos2d@, vector end position |
◆ vec2d() [2/3]
vec2d::vec2d |
( |
const vec2d@ |
other | ) |
|
Construct direction vector from other vector.
- Parameters
-
◆ vec2d() [3/3]
vec2d::vec2d |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Construct direction vector from x and y components.
- Parameters
-
x | double, vector x component
|
y | double, vector y component |
◆ angle()
double vec2d::angle |
( |
const vec2d@ |
other | ) |
const |
angle between: double rad = v.angle(other);
- Parameters
-
other | vec2d@, vector to compute angle relative to this
|
- Returns
- double, angle value in radians
◆ cross()
double vec2d::cross |
( |
const vec2d@ |
other | ) |
const |
cross product: double cp = v.cross(other);
- Parameters
-
other | vec2d@, vector to multiply with
|
- Returns
- double, cross product value
◆ dot()
double vec2d::dot |
( |
const vec2d@ |
other | ) |
const |
dot product: double cp = v.dot(other);
- Parameters
-
other | vec2d@, vector to multiply with
|
- Returns
- double, dot product value
◆ length()
double vec2d::length |
( |
| ) |
const |
length of vector
- Returns
- double, length of vector
◆ normalise()
void vec2d::normalise |
( |
| ) |
|
◆ opAdd()
Add vector to vector, return new vector: vec2d@ v = v0 + v1.
- Parameters
-
- Returns
- vec2d@
◆ opMul()
vec2d@ vec2d::opMul |
( |
double |
f1 | ) |
|
Multiply vector with factor, return new vector: vec2d@ v = v0 * f1.
- Parameters
-
- Returns
- vec2d@
◆ opMul_r()
vec2d@ vec2d::opMul_r |
( |
double |
f1 | ) |
|
Multiply vector with factor, return new vector: vec2d@ v = f1 * v0.
- Parameters
-
- Returns
- vec2d@
◆ opSub()
Subtract vector from vector, return new vector: vec2d@ v = v0 - v1.
- Parameters
-
- Returns
- vec2d@
◆ x()
double vec2d::x |
( |
| ) |
const |
vector x component
- Returns
- double, vector x component
◆ y()
double vec2d::y |
( |
| ) |
const |
vector y component
- Returns
- double, vector y component
The documentation for this class was generated from the following file: