vecmath

package
v1.17.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vecmath is the 3D math of Glutter (SPEC §27.7): vectors, quaternions, matrices, rays, planes, boxes, spheres and frustums in float64, as values that never allocate.

The CPU works in float64 and the GPU in float32 (D30): a CAD scene 50 km wide with a detail of 0.1 mm keeps its precision in the matrices that are multiplied here, and only the result, taken relative to the camera, goes to the GPU through Mat4.Float32.

Matrices are column-major, as WGSL reads them: the entry in row r and column c is m[c*4+r]. A matrix applies to a column vector, so a.Mul(b) applies b first. The clip space is WebGPU's: x and y from -1 to 1, z from 0 to 1, and the view looks down -z. The projections are reversed-Z: the near plane maps to 1 and the far one (or infinity) to 0, which makes the depth of a float32 buffer even over the distance. The rotations are right-handed: a positive angle turns counterclockwise when seen from the positive end of the axis.

Flutter: no counterpart

Index

Constants

This section is empty.

Variables

View Source
var (
	// Vec3Zero is the vector (0, 0, 0).
	//
	// Flutter: no counterpart
	Vec3Zero = Vec3{}
	// Vec3X is the unit vector of the x axis.
	//
	// Flutter: no counterpart
	Vec3X = Vec3{X: 1}
	// Vec3Y is the unit vector of the y axis.
	//
	// Flutter: no counterpart
	Vec3Y = Vec3{Y: 1}
	// Vec3Z is the unit vector of the z axis.
	//
	// Flutter: no counterpart
	Vec3Z = Vec3{Z: 1}
)

The unit vectors and the zero vector. They are values, so no program can change them.

Functions

This section is empty.

Types

type Box3

type Box3 struct {
	// Min is the corner with the smallest coordinates.
	Min Vec3
	// Max is the corner with the largest coordinates.
	Max Vec3
}

Box3 is an axis-aligned box. The empty box has Min above Max, so that Expand and Union of it are the other operand.

Flutter: package:vector_math Aabb3

func EmptyBox3

func EmptyBox3() Box3

EmptyBox3 returns the box that contains no point.

Flutter: no counterpart

func NewBox3

func NewBox3(a, b Vec3) Box3

NewBox3 creates the box with the two corners, in any order.

Flutter: package:vector_math Aabb3.minMax

func (Box3) BoundingSphere

func (b Box3) BoundingSphere() Sphere

BoundingSphere returns the sphere that has the box's center and holds its corners.

Flutter: no counterpart

func (Box3) Center

func (b Box3) Center() Vec3

Center returns the middle of the box.

Flutter: package:vector_math Aabb3.center

func (Box3) Contains

func (b Box3) Contains(p Vec3) bool

Contains says whether the point is in the box, or on its surface.

Flutter: package:vector_math Aabb3.containsVector3

func (Box3) Corner

func (b Box3) Corner(i int) Vec3

Corner returns one of the eight corners: bit 0 of i picks the x, bit 1 the y and bit 2 the z of Max over Min.

Flutter: no counterpart

func (Box3) DistanceTo

func (b Box3) DistanceTo(p Vec3) float64

DistanceTo returns the distance from the point to the box, which is 0 for a point inside.

Flutter: no counterpart

func (Box3) Expand

func (b Box3) Expand(p Vec3) Box3

Expand returns the smallest box that holds the box and the point.

Flutter: package:vector_math Aabb3.hullPoint

func (Box3) Intersects

func (b Box3) Intersects(o Box3) bool

Intersects says whether the boxes share a point.

Flutter: package:vector_math Aabb3.intersectsWithAabb3

func (Box3) IsEmpty

func (b Box3) IsEmpty() bool

IsEmpty says whether the box contains no point.

Flutter: no counterpart

func (Box3) Size

func (b Box3) Size() Vec3

Size returns the lengths of the three sides.

Flutter: no counterpart

func (Box3) Transform

func (b Box3) Transform(m Mat4) Box3

Transform returns the smallest box that holds the box moved by the matrix.

Flutter: package:vector_math Aabb3.transform

func (Box3) Union

func (b Box3) Union(o Box3) Box3

Union returns the smallest box that holds both boxes.

Flutter: package:vector_math Aabb3.hull

type Frustum

type Frustum struct {
	// Planes are, in order, the left, right, bottom, top, near and far planes. The far plane of a projection with an
	// infinite far plane has the zero normal and a distance above 0, so that every point is on its inner side.
	Planes [6]Plane
}

Frustum is the six planes of the volume that a view matrix and a projection see; the normals point inwards, so a point is inside when its distance to every plane is not negative.

Flutter: package:vector_math Frustum

func NewFrustum

func NewFrustum(viewProjection Mat4) Frustum

NewFrustum creates the frustum of a matrix that is a projection times a view (the clip-space matrix of a camera), in WebGPU's clip space.

Flutter: package:vector_math Frustum.matrix

func (Frustum) ContainsPoint

func (f Frustum) ContainsPoint(p Vec3) bool

ContainsPoint says whether the point is inside the frustum.

Flutter: package:vector_math Frustum.containsVector3

func (Frustum) IntersectsBox

func (f Frustum) IntersectsBox(b Box3) bool

IntersectsBox says whether the box is at least partly inside the frustum. It can say true for a box that is outside near an edge of the frustum.

Flutter: package:vector_math Frustum.intersectsWithAabb3

func (Frustum) IntersectsSphere

func (f Frustum) IntersectsSphere(s Sphere) bool

IntersectsSphere says whether the sphere is at least partly inside the frustum. It can say true for a sphere that is outside near a corner of the frustum.

Flutter: package:vector_math Frustum.intersectsWithSphere

type Mat3

type Mat3 [9]float64

Mat3 is a 3x3 matrix, stored column-major: the entry in row r and column c is m[c*3+r].

Flutter: package:vector_math Matrix3

func Mat3Identity

func Mat3Identity() Mat3

Mat3Identity returns the identity matrix.

Flutter: package:vector_math Matrix3.identity

func (Mat3) Det

func (a Mat3) Det() float64

Det returns the determinant.

Flutter: package:vector_math Matrix3.determinant

func (Mat3) Float32

func (a Mat3) Float32() [9]float32

Float32 returns the entries as float32, in the same order.

Flutter: no counterpart

func (Mat3) Inverse

func (a Mat3) Inverse() (Mat3, bool)

Inverse returns the inverse matrix, and false when the matrix is singular (its determinant is 0 or not a number).

Flutter: package:vector_math Matrix3.invert

func (Mat3) Mul

func (a Mat3) Mul(b Mat3) Mat3

Mul returns the product: the matrix that applies b first, then a.

Flutter: package:vector_math Matrix3.operator*

func (Mat3) MulVec3

func (a Mat3) MulVec3(v Vec3) Vec3

MulVec3 returns the vector transformed by the matrix.

Flutter: package:vector_math Matrix3.transform

func (Mat3) Transpose

func (a Mat3) Transpose() Mat3

Transpose returns the matrix with rows and columns exchanged.

Flutter: package:vector_math Matrix3.transposed

type Mat4

type Mat4 [16]float64

Mat4 is a 4x4 matrix, stored column-major as WGSL reads it: the entry in row r and column c is m[c*4+r]. It applies to column vectors, so a.Mul(b) applies b first.

Flutter: package:vector_math Matrix4

func LookAt

func LookAt(eye, center, up Vec3) Mat4

LookAt creates the view matrix of a camera at eye that looks at center, with up as its upward direction: the matrix that turns world space into the space of the camera, which looks down -z. It returns the identity when eye and center are the same point, or when up is along the view.

Flutter: package:vector_math setViewMatrix

func Mat4Identity

func Mat4Identity() Mat4

Mat4Identity returns the identity matrix.

Flutter: package:vector_math Matrix4.identity

func NewMat4FromMatrix4

func NewMat4FromMatrix4(m *ui.Matrix4) Mat4

NewMat4FromMatrix4 creates the matrix from a float32 matrix of the engine API.

Flutter: no counterpart

func NewMat4RotationX

func NewMat4RotationX(angle float64) Mat4

NewMat4RotationX creates the rotation around the x axis by the angle in radians.

Flutter: package:vector_math Matrix4.rotationX

func NewMat4RotationY

func NewMat4RotationY(angle float64) Mat4

NewMat4RotationY creates the rotation around the y axis by the angle in radians.

Flutter: package:vector_math Matrix4.rotationY

func NewMat4RotationZ

func NewMat4RotationZ(angle float64) Mat4

NewMat4RotationZ creates the rotation around the z axis by the angle in radians.

Flutter: package:vector_math Matrix4.rotationZ

func NewMat4Scale

func NewMat4Scale(v Vec3) Mat4

NewMat4Scale creates the matrix that scales by v along the axes.

Flutter: package:vector_math Matrix4.diagonal3

func NewMat4TRS

func NewMat4TRS(translation Vec3, rotation Quat, scale Vec3) Mat4

NewMat4TRS creates the matrix that scales, then rotates, then moves.

Flutter: package:vector_math Matrix4.compose

func NewMat4Translation

func NewMat4Translation(v Vec3) Mat4

NewMat4Translation creates the matrix that moves points by v.

Flutter: package:vector_math Matrix4.translation

func Orthographic

func Orthographic(left, right, bottom, top, near, far float64) Mat4

Orthographic creates a projection of the box that goes from left to right, bottom to top, and from near to far in front of the eye, in WebGPU's clip space with reversed-Z: the depth is 1 at near and 0 at far. Near may be negative (a plane behind the eye).

Flutter: package:vector_math setOrthographicMatrix

func Perspective

func Perspective(fovY, aspect, near float64) Mat4

Perspective creates a projection with the vertical field of view fovY, in radians, the aspect (width over height) and the near plane, in WebGPU's clip space with reversed-Z and the far plane at infinity: a point at the near plane gets the depth 1 and a point infinitely far gets 0.

Flutter: package:vector_math setPerspectiveMatrix

func PerspectiveFinite

func PerspectiveFinite(fovY, aspect, near, far float64) Mat4

PerspectiveFinite is Perspective with a far plane: the depth is 1 at near and 0 at far.

Flutter: package:vector_math setPerspectiveMatrix

func (Mat4) Det

func (a Mat4) Det() float64

Det returns the determinant.

Flutter: package:vector_math Matrix4.determinant

func (Mat4) Float32

func (a Mat4) Float32() [16]float32

Float32 returns the entries as float32, in the same order (what a uniform buffer takes).

Flutter: no counterpart

func (Mat4) Inverse

func (a Mat4) Inverse() (Mat4, bool)

Inverse returns the inverse matrix, and false when the matrix is singular (its determinant is 0 or not a number).

Flutter: package:vector_math Matrix4.invert

func (Mat4) Mat3

func (a Mat4) Mat3() Mat3

Mat3 returns the upper left 3x3 block: the rotation and the scale.

Flutter: package:vector_math Matrix4.getRotation

func (Mat4) Matrix4

func (a Mat4) Matrix4() ui.Matrix4

Matrix4 returns the matrix as the float32 matrix of the engine API (what a Canvas takes).

Flutter: no counterpart

func (Mat4) Mul

func (a Mat4) Mul(b Mat4) Mat4

Mul returns the product: the matrix that applies b first, then a.

Flutter: package:vector_math Matrix4.operator*

func (Mat4) MulVec4

func (a Mat4) MulVec4(v Vec4) Vec4

MulVec4 returns the vector transformed by the matrix.

Flutter: package:vector_math Matrix4.transform

func (Mat4) NearlyEqual

func (a Mat4) NearlyEqual(b Mat4, eps float64) bool

NearlyEqual says whether every entry of a is within eps of b's.

Flutter: no counterpart

func (Mat4) NormalMatrix

func (a Mat4) NormalMatrix() Mat3

NormalMatrix returns the matrix for the normals of a surface: the inverse transpose of the upper left block. It is the identity block when that one is singular.

Flutter: package:vector_math Matrix4.copyNormalMatrix

func (Mat4) ProjectPoint

func (a Mat4) ProjectPoint(p Vec3) (ndc Vec3, w float64)

ProjectPoint returns the point transformed by the matrix and divided by its w: the point of normalized device coordinates for a projection matrix, and the point behind the eye gets the negative w of the clip point in the second result.

Flutter: package:vector_math Matrix4.perspectiveTransform

func (Mat4) TransformDirection

func (a Mat4) TransformDirection(v Vec3) Vec3

TransformDirection returns the vector turned and scaled by the matrix, without its translation.

Flutter: package:vector_math Matrix4.rotate3

func (Mat4) TransformPoint

func (a Mat4) TransformPoint(p Vec3) Vec3

TransformPoint returns the point moved by the matrix, with w taken as 1 and the result not divided by its w: right for the matrices of an object, not for a projection (use ProjectPoint).

Flutter: package:vector_math Matrix4.transform3

func (Mat4) Translation

func (a Mat4) Translation() Vec3

Translation returns the last column's first three entries: where the matrix moves the origin.

Flutter: package:vector_math Matrix4.getTranslation

func (Mat4) Transpose

func (a Mat4) Transpose() Mat4

Transpose returns the matrix with rows and columns exchanged.

Flutter: package:vector_math Matrix4.transposed

func (Mat4) WithTranslation

func (a Mat4) WithTranslation(t Vec3) Mat4

WithTranslation returns the matrix with its translation set to t.

Flutter: package:vector_math Matrix4.setTranslation

type Plane

type Plane struct {
	// Normal is the direction that is perpendicular to the plane.
	Normal Vec3
	// D is minus the dot product of the normal with any point of the plane.
	D float64
}

Plane is the points p with Normal.Dot(p) + D = 0. When Normal has length 1, DistanceTo is the distance in the units of the scene, positive on the side that the normal points to.

Flutter: package:vector_math Plane

func NewPlaneFromPointNormal

func NewPlaneFromPointNormal(point, normal Vec3) Plane

NewPlaneFromPointNormal creates the plane through the point, perpendicular to the normal (which is made of length 1).

Flutter: package:vector_math Plane.components

func NewPlaneFromPoints

func NewPlaneFromPoints(a, b, c Vec3) Plane

NewPlaneFromPoints creates the plane through the three points; its normal is the one that a counterclockwise triangle a, b, c points to. Points on one line give the plane with the zero normal.

Flutter: package:vector_math Plane.setFromPoints

func (Plane) ClosestPoint

func (p Plane) ClosestPoint(v Vec3) Vec3

ClosestPoint returns the point of the plane that is nearest to v.

Flutter: no counterpart

func (Plane) DistanceTo

func (p Plane) DistanceTo(v Vec3) float64

DistanceTo returns the signed distance of the point to the plane.

Flutter: package:vector_math Plane.distanceToVector3

func (Plane) Flip

func (p Plane) Flip() Plane

Flip returns the plane that faces the other way.

Flutter: no counterpart

type Quat

type Quat struct {
	// X is the i component.
	X float64
	// Y is the j component.
	Y float64
	// Z is the k component.
	Z float64
	// W is the real component.
	W float64
}

Quat is a quaternion x*i + y*j + z*k + w. A rotation is a quaternion of length 1 (the identity has w = 1), and a.Mul(b) applies b first, as for matrices.

Flutter: package:vector_math Quaternion

func NewQuatAxisAngle

func NewQuatAxisAngle(axis Vec3, angle float64) Quat

NewQuatAxisAngle creates the rotation of the angle, in radians, around the axis (which need not have length 1). An axis without length gives the identity.

Flutter: package:vector_math Quaternion.axisAngle

func NewQuatBasis

func NewQuatBasis(x, y, z Vec3) Quat

NewQuatBasis creates the rotation that turns the x, y and z axes into the three vectors, which must be perpendicular and of length 1.

Flutter: no counterpart

func NewQuatFromTo

func NewQuatFromTo(from, to Vec3) Quat

NewQuatFromTo creates the shortest rotation that turns the direction from into the direction to. Directions without length give the identity.

Flutter: package:vector_math Quaternion.fromTwoVectors

func QuatIdentity

func QuatIdentity() Quat

QuatIdentity is the rotation that does nothing.

Flutter: package:vector_math Quaternion.identity

func (Quat) AxisAngle

func (a Quat) AxisAngle() (Vec3, float64)

AxisAngle returns the axis, of length 1, and the angle, from 0 to 2 pi, of the rotation. The identity has the axis (1, 0, 0) and the angle 0.

Flutter: package:vector_math Quaternion.radians

func (Quat) Conjugate

func (a Quat) Conjugate() Quat

Conjugate returns the quaternion with the vector part negated, which is the inverse of a rotation.

Flutter: package:vector_math Quaternion.conjugated

func (Quat) Dot

func (a Quat) Dot(b Quat) float64

Dot returns the dot product, as of 4D vectors.

Flutter: package:vector_math Quaternion.dot

func (Quat) Inverse

func (a Quat) Inverse() Quat

Inverse returns the inverse of the quaternion, which is the conjugate for a rotation. A quaternion without length gives the identity.

Flutter: package:vector_math Quaternion.inverted

func (Quat) Length

func (a Quat) Length() float64

Length returns the length.

Flutter: package:vector_math Quaternion.length

func (Quat) Mat3

func (a Quat) Mat3() Mat3

Mat3 returns the rotation as a matrix. The quaternion should have length 1.

Flutter: package:vector_math Quaternion.asRotationMatrix

func (Quat) Mat4

func (a Quat) Mat4() Mat4

Mat4 returns the rotation as a matrix. The quaternion should have length 1.

Flutter: no counterpart

func (Quat) Mul

func (a Quat) Mul(b Quat) Quat

Mul returns the product: the rotation that applies b first, then a.

Flutter: package:vector_math Quaternion.operator*

func (Quat) Normalize

func (a Quat) Normalize() Quat

Normalize returns the quaternion of length 1 in the direction of a, or the identity when a has no length.

Flutter: package:vector_math Quaternion.normalized

func (Quat) Rotate

func (a Quat) Rotate(v Vec3) Vec3

Rotate returns the vector turned by the rotation.

Flutter: package:vector_math Quaternion.rotate

func (Quat) Slerp

func (a Quat) Slerp(b Quat, t float64) Quat

Slerp returns the rotation at t of the way from a to b on the shortest arc.

Flutter: no counterpart

type Ray

type Ray struct {
	// Origin is where the ray starts.
	Origin Vec3
	// Dir is the direction of the ray, normally of length 1; the t of the methods is in units of its length.
	Dir Vec3
}

Ray is a half line: the points Origin + t*Dir for t >= 0.

Flutter: package:vector_math Ray

func (Ray) At

func (r Ray) At(t float64) Vec3

At returns the point at t along the ray.

Flutter: package:vector_math Ray.at

func (Ray) IntersectBox

func (r Ray) IntersectBox(b Box3) (float64, bool)

IntersectBox returns the t where the ray enters the box, which is 0 when the origin is inside, and false when the ray misses the box.

Flutter: package:vector_math Ray.intersectsWithAabb3

func (Ray) IntersectPlane

func (r Ray) IntersectPlane(p Plane) (float64, bool)

IntersectPlane returns the t where the ray meets the plane, and false when it never does: the ray is parallel to the plane, or the plane is behind the origin.

Flutter: no counterpart

func (Ray) IntersectSphere

func (r Ray) IntersectSphere(s Sphere) (float64, bool)

IntersectSphere returns the t where the ray enters the sphere (0 when the origin is inside), and false when it misses.

Flutter: package:vector_math Ray.intersectsWithSphere

func (Ray) IntersectTriangle

func (r Ray) IntersectTriangle(a, b, c Vec3) (float64, bool)

IntersectTriangle returns the t where the ray meets the triangle, and false when it misses it or is parallel.

Flutter: package:vector_math Ray.intersectsWithTriangle

func (Ray) Transform

func (r Ray) Transform(m Mat4) Ray

Transform returns the ray moved by the matrix: the origin as a point and the direction as a vector.

Flutter: no counterpart

type Sphere

type Sphere struct {
	// Center is the middle of the ball.
	Center Vec3
	// Radius is the distance from the center to the surface.
	Radius float64
}

Sphere is a ball.

Flutter: package:vector_math Sphere

func (Sphere) Contains

func (s Sphere) Contains(p Vec3) bool

Contains says whether the point is in the ball.

Flutter: package:vector_math Sphere.containsVector3

func (Sphere) Intersects

func (s Sphere) Intersects(o Sphere) bool

Intersects says whether the balls share a point.

Flutter: package:vector_math Sphere.intersectsWithSphere

type Vec2

type Vec2 struct {
	// X is the first component.
	X float64
	// Y is the second component.
	Y float64
}

Vec2 is a 2D vector.

Flutter: package:vector_math Vector2

func NewVec2

func NewVec2(x, y float64) Vec2

NewVec2 creates the vector.

Flutter: package:vector_math Vector2.new

func (Vec2) Add

func (a Vec2) Add(b Vec2) Vec2

Add returns the sum of the vectors.

Flutter: package:vector_math Vector2.operator+

func (Vec2) Cross

func (a Vec2) Cross(b Vec2) float64

Cross returns the z component of the cross product of the vectors seen as 3D.

Flutter: package:vector_math Vector2.cross

func (Vec2) Dot

func (a Vec2) Dot(b Vec2) float64

Dot returns the dot product.

Flutter: package:vector_math Vector2.dot

func (Vec2) Float32

func (a Vec2) Float32() [2]float32

Float32 returns the components as float32.

Flutter: no counterpart

func (Vec2) Length

func (a Vec2) Length() float64

Length returns the length.

Flutter: package:vector_math Vector2.length

func (Vec2) LengthSq

func (a Vec2) LengthSq() float64

LengthSq returns the squared length.

Flutter: package:vector_math Vector2.length2

func (Vec2) Lerp

func (a Vec2) Lerp(b Vec2, t float64) Vec2

Lerp returns the point at t of the way from a to b.

Flutter: package:vector_math Vector2.mix

func (Vec2) Neg

func (a Vec2) Neg() Vec2

Neg returns the opposite vector.

Flutter: package:vector_math Vector2.operator-

func (Vec2) Normalize

func (a Vec2) Normalize() Vec2

Normalize returns the vector of length 1 with the direction of a, or the zero vector when a has no length.

Flutter: package:vector_math Vector2.normalized

func (Vec2) Scale

func (a Vec2) Scale(s float64) Vec2

Scale returns the vector times the number.

Flutter: package:vector_math Vector2.scale

func (Vec2) Sub

func (a Vec2) Sub(b Vec2) Vec2

Sub returns the difference of the vectors.

Flutter: package:vector_math Vector2.operator-

type Vec3

type Vec3 struct {
	// X is the first component.
	X float64
	// Y is the second component.
	Y float64
	// Z is the third component.
	Z float64
}

Vec3 is a 3D vector or point.

Flutter: package:vector_math Vector3

func NewVec3

func NewVec3(x, y, z float64) Vec3

NewVec3 creates the vector.

Flutter: package:vector_math Vector3.new

func (Vec3) Add

func (a Vec3) Add(b Vec3) Vec3

Add returns the sum of the vectors.

Flutter: package:vector_math Vector3.operator+

func (Vec3) AngleTo

func (a Vec3) AngleTo(b Vec3) float64

AngleTo returns the angle between the vectors, from 0 to pi. It is 0 when one of them has no length.

Flutter: package:vector_math Vector3.angleTo

func (Vec3) Cross

func (a Vec3) Cross(b Vec3) Vec3

Cross returns the cross product, which is perpendicular to both vectors, with the right-hand rule.

Flutter: package:vector_math Vector3.cross

func (Vec3) DistanceSqTo

func (a Vec3) DistanceSqTo(b Vec3) float64

DistanceSqTo returns the squared distance between the points.

Flutter: package:vector_math Vector3.distanceToSquared

func (Vec3) DistanceTo

func (a Vec3) DistanceTo(b Vec3) float64

DistanceTo returns the distance between the points.

Flutter: package:vector_math Vector3.distanceTo

func (Vec3) Dot

func (a Vec3) Dot(b Vec3) float64

Dot returns the dot product.

Flutter: package:vector_math Vector3.dot

func (Vec3) Float32

func (a Vec3) Float32() [3]float32

Float32 returns the components as float32.

Flutter: no counterpart

func (Vec3) IsFinite

func (a Vec3) IsFinite() bool

IsFinite says whether no component is infinite or NaN.

Flutter: no counterpart

func (Vec3) Length

func (a Vec3) Length() float64

Length returns the length.

Flutter: package:vector_math Vector3.length

func (Vec3) LengthSq

func (a Vec3) LengthSq() float64

LengthSq returns the squared length.

Flutter: package:vector_math Vector3.length2

func (Vec3) Lerp

func (a Vec3) Lerp(b Vec3, t float64) Vec3

Lerp returns the point at t of the way from a to b.

Flutter: package:vector_math Vector3.mix

func (Vec3) Max

func (a Vec3) Max(b Vec3) Vec3

Max returns the largest of each component.

Flutter: package:vector_math Vector3.max

func (Vec3) Min

func (a Vec3) Min(b Vec3) Vec3

Min returns the smallest of each component.

Flutter: package:vector_math Vector3.min

func (Vec3) MulComponents

func (a Vec3) MulComponents(b Vec3) Vec3

MulComponents returns the product of the components, one by one.

Flutter: package:vector_math Vector3.operator*

func (Vec3) NearlyEqual

func (a Vec3) NearlyEqual(b Vec3, eps float64) bool

NearlyEqual says whether every component of a is within eps of b's.

Flutter: no counterpart

func (Vec3) Neg

func (a Vec3) Neg() Vec3

Neg returns the opposite vector.

Flutter: package:vector_math Vector3.operator-

func (Vec3) Normalize

func (a Vec3) Normalize() Vec3

Normalize returns the vector of length 1 with the direction of a, or the zero vector when a has no length.

Flutter: package:vector_math Vector3.normalized

func (Vec3) Perpendicular

func (a Vec3) Perpendicular() Vec3

Perpendicular returns a unit vector that is perpendicular to a, or the zero vector when a has no length.

Flutter: no counterpart

func (Vec3) ProjectOnto

func (a Vec3) ProjectOnto(b Vec3) Vec3

ProjectOnto returns the part of a that is along b, or the zero vector when b has no length.

Flutter: no counterpart

func (Vec3) Reflect

func (a Vec3) Reflect(n Vec3) Vec3

Reflect returns the vector reflected by the surface with the normal n, which has length 1.

Flutter: package:vector_math Vector3.reflect

func (Vec3) Scale

func (a Vec3) Scale(s float64) Vec3

Scale returns the vector times the number.

Flutter: package:vector_math Vector3.scale

func (Vec3) Sub

func (a Vec3) Sub(b Vec3) Vec3

Sub returns the difference of the vectors.

Flutter: package:vector_math Vector3.operator-

func (Vec3) Vec4

func (a Vec3) Vec4(w float64) Vec4

Vec4 makes a vector of four components with w.

Flutter: no counterpart

type Vec4

type Vec4 struct {
	// X is the first component.
	X float64
	// Y is the second component.
	Y float64
	// Z is the third component.
	Z float64
	// W is the fourth component.
	W float64
}

Vec4 is a 4D vector, or a point in homogeneous coordinates.

Flutter: package:vector_math Vector4

func NewVec4

func NewVec4(x, y, z, w float64) Vec4

NewVec4 creates the vector.

Flutter: package:vector_math Vector4.new

func (Vec4) Add

func (a Vec4) Add(b Vec4) Vec4

Add returns the sum of the vectors.

Flutter: package:vector_math Vector4.operator+

func (Vec4) Dot

func (a Vec4) Dot(b Vec4) float64

Dot returns the dot product.

Flutter: package:vector_math Vector4.dot

func (Vec4) Float32

func (a Vec4) Float32() [4]float32

Float32 returns the components as float32.

Flutter: no counterpart

func (Vec4) Lerp

func (a Vec4) Lerp(b Vec4, t float64) Vec4

Lerp returns the point at t of the way from a to b.

Flutter: package:vector_math Vector4.mix

func (Vec4) PerspectiveDivide

func (a Vec4) PerspectiveDivide() Vec3

PerspectiveDivide returns the first three components divided by w: the point of normalized device coordinates that a clip-space point stands for. A w of 0 gives infinities.

Flutter: no counterpart

func (Vec4) Scale

func (a Vec4) Scale(s float64) Vec4

Scale returns the vector times the number.

Flutter: package:vector_math Vector4.scale

func (Vec4) Sub

func (a Vec4) Sub(b Vec4) Vec4

Sub returns the difference of the vectors.

Flutter: package:vector_math Vector4.operator-

func (Vec4) XYZ

func (a Vec4) XYZ() Vec3

XYZ returns the first three components.

Flutter: package:vector_math Vector4.xyz

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL