zscript-doc/api/base/Vector.md

34 lines
457 B
Markdown
Raw Normal View History

2018-12-29 16:05:19 -08:00
# Vector2/Vector3
Vectors have builtin methods and `Vector3` in particular has a swizzle
operator.
2018-12-29 16:05:19 -08:00
```
struct Vector2
{
double x, y;
double Length() const;
vector2 Unit() const;
}
struct Vector3
{
double x, y, z;
vector2 xy;
double Length() const;
vector3 Unit() const;
}
```
2019-08-14 03:31:41 -07:00
### `Length`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
Returns the length (magnitude) of the vector.
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
### `Unit`
2018-12-29 16:05:19 -08:00
2019-08-14 03:31:41 -07:00
Returns a normalized vector. Equivalent to `vec / vec.Length()`.
2018-12-29 16:05:19 -08:00
<!-- EOF -->