Documentation
¶
Index ¶
- Constants
- Variables
- func ActiveTexture(texID uint32, uniformId string, program uint32, texActive uint32) int32
- func Clamp(x, a, b float32) float32
- func ColToFloats(col uint32) []float32
- func CreateLathe(lpath []Vec2, inverted, startAngle, endAngle, rise float32, ...) []float32
- func CreateShaderProgram(vertexShader, fragShader *Shader, attributes []string) (uint32, string)
- func CreateVCone(radius, radius2, height float32, sides int) []float32
- func DegToRad(degrees float32) float32
- func DrawQuads(verts []float32)
- func DrawSharedQuads(verts []float32, edges int)
- func Find(str, find string, index int) int
- func GLVersion() string
- func GetAttributes(vertShaderSource string) ([]string, string)
- func GetSetFloat(program uint32, name *uint8, v float32) int32
- func GetSetInt(program uint32, name *uint8, v int32) int32
- func GetSetVec3(program uint32, name *uint8, vec []float32) int32
- func OpenTextFile(path string) string
- func RadToDeg(radians float32) float32
- func SetFog(refs []int32, minDist, maxDist float32, colour []float32)
- func SetRenderBuffer(bufID uint32, stride int32)
- func SetTexture(uniformId string, program uint32, texLoc int32) int32
- func Vec3toCol(v *Vec3) uint32
- func Vec3toFloats(v *Vec3) []float32
- type Mat4s
- func (m *Mat4s) CopyFrom(src *Mat4s)
- func (m *Mat4s) CopyPos(src *Mat4s)
- func (m *Mat4s) Determinant() float32
- func (m *Mat4s) ExtractRotation(src *Mat4s)
- func (m *Mat4s) FromArray(array []float32, offset int)
- func (m *Mat4s) GetMaxScaleOnAxis() float32
- func (m *Mat4s) Inverse() (*Mat4s, error)
- func (m *Mat4s) LookAt(eye, target, up Vec3)
- func (m *Mat4s) Mul(other *Mat4s) *Mat4s
- func (m *Mat4s) MulMatrices(a, b *Mat4s)
- func (m *Mat4s) MulScalar(s float32)
- func (m *Mat4s) Pos() Vec3
- func (m *Mat4s) ScaleCols(v Vec3) *Mat4s
- func (m *Mat4s) Set(...)
- func (m *Mat4s) SetFrustum(left, right, bottom, top, near, far float32)
- func (m *Mat4s) SetIdentity()
- func (m *Mat4s) SetInverse(src *Mat4s) error
- func (m *Mat4s) SetMul(other *Mat4s)
- func (m *Mat4s) SetOrthographic(width, height, near, far float32)
- func (m *Mat4s) SetPerspective(fov, aspect, near, far float32)
- func (m *Mat4s) SetPos(v Vec3)
- func (m *Mat4s) SetRotationAxis(axis *Vec3, angle float32)
- func (m *Mat4s) SetRotationFromEuler(euler Vec3)
- func (m *Mat4s) SetRotationFromQuat(q Quat)
- func (m *Mat4s) SetRotationX(theta float32)
- func (m *Mat4s) SetRotationY(theta float32)
- func (m *Mat4s) SetRotationZ(theta float32)
- func (m *Mat4s) SetScale(x, y, z float32)
- func (m *Mat4s) SetScaleCols(v Vec3)
- func (m *Mat4s) SetTransform(pos Vec3, quat Quat, scale Vec3)
- func (m *Mat4s) SetTranslation(x, y, z float32)
- func (m *Mat4s) SetTranspose()
- func (m *Mat4s) SetVkFrustum(left, right, bottom, top, near, far float32)
- func (m *Mat4s) SetVkPerspective(fov, aspect, near, far float32)
- func (m *Mat4s) SetZero()
- func (m *Mat4s) ToArray() []float32
- func (m *Mat4s) Transpose() *Mat4s
- type Mesh
- type Mouse
- type Quat
- func (q *Quat) Conjugate() Quat
- func (q *Quat) Dot(other Quat) float32
- func (q *Quat) FromArray(array []float32, offset int)
- func (q *Quat) GenGoNew() string
- func (q *Quat) GenGoSet(path string) string
- func (q *Quat) Inverse() Quat
- func (q *Quat) IsEqual(other Quat) bool
- func (q *Quat) IsIdentity() bool
- func (q *Quat) IsNil() bool
- func (q Quat) Length() float32
- func (q Quat) LengthSq() float32
- func (q *Quat) Mul(other Quat) Quat
- func (q *Quat) MulQuats(a, b Quat)
- func (q *Quat) Normalize()
- func (q *Quat) NormalizeFast()
- func (q *Quat) Set(x, y, z, w float32)
- func (q *Quat) SetConjugate()
- func (q *Quat) SetFromAxisAngle(axis Vec3, angle float32)
- func (q *Quat) SetFromEuler(euler Vec3)
- func (q *Quat) SetFromRotationMatrix(m *Mat4s)
- func (q *Quat) SetFromUnitVectors(vFrom, vTo Vec3)
- func (q *Quat) SetIdentity()
- func (q *Quat) SetInverse()
- func (q *Quat) SetMul(other Quat)
- func (q *Quat) Slerp(other Quat, t float32)
- func (q Quat) String() string
- func (q *Quat) ToArray(array []float32, offset int)
- func (q *Quat) ToAxisAngle() Vec4
- type RenderBuffer
- type Scene
- type Shader
- type ShaderSettings
- type Shape
- func (c *Shape) CreateCone() []float32
- func (c *Shape) CreateCuboid() []float32
- func (c *Shape) CreateCylinder() []float32
- func (c *Shape) CreatePlane() []float32
- func (c *Shape) CreateSphere() []float32
- func (c *Shape) CreateSpring() []float32
- func (c *Shape) CreateTCone() []float32
- func (c *Shape) CreateTorus() []float32
- func (c *Shape) CreateTube() []float32
- func (s *Shape) Draw()
- func (s *Shape) DrawTriangles()
- type ShapeType
- type Texture
- type UserInput
- type Vec2
- type Vec3
- func (v Vec3) Abs() Vec3
- func (v Vec3) Add(other Vec3) Vec3
- func (v Vec3) AddScalar(s float32) Vec3
- func (v *Vec3) AlmostEqual(other Vec3, tol float32) bool
- func (v Vec3) AngleTo(other Vec3) float32
- func (v Vec3) Ceil() Vec3
- func (v *Vec3) Clamp(min, max Vec3)
- func (v *Vec3) ClampScalar(minVal, maxVal float32)
- func (v Vec3) CosTo(other Vec3) float32
- func (v Vec3) Cross(other Vec3) Vec3
- func (v Vec3) DistTo(other Vec3) float32
- func (v Vec3) DistToSquared(other Vec3) float32
- func (v Vec3) Div(other Vec3) Vec3
- func (v Vec3) DivScalar(scalar float32) Vec3
- func (v Vec3) Dot(other Vec3) float32
- func (v Vec3) Floor() Vec3
- func (v Vec3) IsEqual(other Vec3) bool
- func (v Vec3) Length() float32
- func (v Vec3) LengthSq() float32
- func (v Vec3) Lerp(other Vec3, alpha float32) Vec3
- func (v Vec3) Max(other Vec3) Vec3
- func (v Vec3) Min(other Vec3) Vec3
- func (v Vec3) Mul(other Vec3) Vec3
- func (v Vec3) MulMat4(m *Mat4s) Vec3
- func (v Vec3) MulProjection(m *Mat4s) Vec3
- func (v Vec3) MulQuat(q Quat) Vec3
- func (v Vec3) MulScalar(s float32) Vec3
- func (v Vec3) NDCToWindow(size, off Vec2, near, far float32, flipY bool) Vec3
- func (v Vec3) Negate() Vec3
- func (v Vec3) Normal() Vec3
- func (v *Vec3) Normalize()
- func (v *Vec3) ProjectOnPlane(planeNormal Vec3) Vec3
- func (v *Vec3) ProjectOnVector(other Vec3) Vec3
- func (v *Vec3) RandomTangents() (Vec3, Vec3)
- func (v *Vec3) Reflect(normal Vec3) Vec3
- func (v Vec3) RotateAxisAngle(axis Vec3, angle float32) Vec3
- func (v Vec3) Round() Vec3
- func (v *Vec3) Set(x, y, z float32)
- func (v *Vec3) SetAdd(other Vec3)
- func (v *Vec3) SetAddScalar(s float32)
- func (v *Vec3) SetCeil()
- func (v *Vec3) SetDiv(other Vec3)
- func (v *Vec3) SetDivScalar(s float32)
- func (v *Vec3) SetEulerAnglesFromMatrix(m *Mat4s)
- func (v *Vec3) SetEulerAnglesFromQuat(q Quat)
- func (v *Vec3) SetFloor()
- func (v *Vec3) SetFromMatrixPos(m *Mat4s)
- func (v *Vec3) SetLength(l float32)
- func (v *Vec3) SetLerp(other Vec3, alpha float32)
- func (v *Vec3) SetMax(other Vec3)
- func (v *Vec3) SetMin(other Vec3)
- func (v *Vec3) SetMul(other Vec3)
- func (v *Vec3) SetMulMat4(m *Mat4s)
- func (v *Vec3) SetMulQuat(q Quat)
- func (v *Vec3) SetMulScalar(s float32)
- func (v *Vec3) SetNegate()
- func (v *Vec3) SetNormal()
- func (v *Vec3) SetRotateAxisAngle(axis Vec3, angle float32)
- func (v *Vec3) SetRound()
- func (v *Vec3) SetScalar(s float32)
- func (v *Vec3) SetSub(other Vec3)
- func (v *Vec3) SetSubScalar(s float32)
- func (v *Vec3) SetZero()
- func (v Vec3) Sub(other Vec3) Vec3
- func (v Vec3) SubScalar(s float32) Vec3
- type Vec4
- func (v Vec4) Add(other Vec4) Vec4
- func (v Vec4) AddScalar(s float32) Vec4
- func (v *Vec4) AlmostEqual(other Vec4, tol float32) bool
- func (v Vec4) Ceil() Vec4
- func (v *Vec4) Clamp(min, max Vec4)
- func (v *Vec4) ClampScalar(minVal, maxVal float32)
- func (v Vec4) Div(other Vec4) Vec4
- func (v Vec4) DivScalar(scalar float32) Vec4
- func (v Vec4) Dot(other Vec4) float32
- func (v Vec4) Floor() Vec4
- func (v *Vec4) FromArray(array []float32, offset int)
- func (v *Vec4) IsEqual(other Vec4) bool
- func (v Vec4) Length() float32
- func (v Vec4) LengthSq() float32
- func (v Vec4) Lerp(other Vec4, alpha float32) Vec4
- func (v Vec4) Max(other Vec4) Vec4
- func (v Vec4) Min(other Vec4) Vec4
- func (v Vec4) Mul(other Vec4) Vec4
- func (v Vec4) MulMat4(m *Mat4s) Vec4
- func (v Vec4) MulScalar(s float32) Vec4
- func (v Vec4) Negate() Vec4
- func (v Vec4) Normal() Vec4
- func (v *Vec4) Normalize()
- func (v Vec4) PerspDiv() Vec3
- func (v Vec4) Round() Vec4
- func (v *Vec4) Set(x, y, z, w float32)
- func (v *Vec4) SetAdd(other Vec4)
- func (v *Vec4) SetAddScalar(s float32)
- func (v *Vec4) SetAxisAngleFromQuat(q Quat)
- func (v *Vec4) SetAxisFromRotationMatrix(m *Mat4s)
- func (v *Vec4) SetByName(name string, value float32)
- func (v *Vec4) SetCeil()
- func (v *Vec4) SetDiv(other Vec4)
- func (v *Vec4) SetDivScalar(s float32)
- func (v *Vec4) SetFloor()
- func (v *Vec4) SetFromVec2(other Vec2)
- func (v *Vec4) SetFromVec3(other Vec3, w float32)
- func (v *Vec4) SetLength(l float32)
- func (v *Vec4) SetLerp(other *Vec4, alpha float32)
- func (v *Vec4) SetMax(other Vec4)
- func (v *Vec4) SetMin(other Vec4)
- func (v *Vec4) SetMul(other Vec4)
- func (v *Vec4) SetMulScalar(s float32)
- func (v *Vec4) SetNegate()
- func (v *Vec4) SetNormal()
- func (v *Vec4) SetRound()
- func (v *Vec4) SetSub(other Vec4)
- func (v *Vec4) SetSubScalar(s float32)
- func (v *Vec4) SetZero()
- func (v Vec4) String() string
- func (v Vec4) Sub(other Vec4) Vec4
- func (v Vec4) SubScalar(s float32) Vec4
- func (v Vec4) ToArray(array []float32, offset int)
Constants ¶
const ( // DegToRadFactor is the number of radians per degree. DegToRadFactor = math32.Pi / 180 // RadToDegFactor is the number of degrees per radian. RadToDegFactor = 180 / math32.Pi )
const VERTSIZE = 9
Variables ¶
var Infinity = float32(math32.Inf(1))
Infinity is positive infinity.
Functions ¶
func ActiveTexture ¶
func ColToFloats ¶
func CreateLathe ¶
func CreateShaderProgram ¶
func CreateVCone ¶
func DrawSharedQuads ¶
func GetAttributes ¶
func OpenTextFile ¶
func SetRenderBuffer ¶
func Vec3toFloats ¶
Types ¶
type Mat4s ¶
type Mat4s struct {
// contains filtered or unexported fields
}
Mat4 is 4x4 matrix organized internally as column matrix.
func NewLookAt ¶
NewLookAt returns Mat4 matrix as view transform matrix with origin at eye, looking at target and using the up vector.
func (*Mat4s) CopyFrom ¶
CopyFrom copies from source matrix into this matrix (a regular = assign does not copy data, just the pointer!)
func (*Mat4s) Determinant ¶
Determinant calculates and returns the determinat of this matrix.
func (*Mat4s) ExtractRotation ¶
ExtractRotation sets this matrix as rotation matrix from the src transformation matrix.
func (*Mat4s) GetMaxScaleOnAxis ¶
GetMaxScaleOnAxis returns the maximum scale value of the 3 axes.
func (*Mat4s) Inverse ¶
Inverse returns the inverse of this matrix. If the matrix cannot be inverted returns error and sets this matrix to the identity matrix.
func (*Mat4s) LookAt ¶
LookAt sets this matrix as view transform matrix with origin at eye, looking at target and using the up vector.
func (*Mat4s) MulMatrices ¶
MulMatrices sets this matrix as matrix multiplication a by b (i.e. b*a).
func (*Mat4s) MulScalar ¶
SetMulScalar multiplies each element of this matrix by the specified scalar.
func (*Mat4s) ScaleCols ¶
ScaleCols returns matrix with first column of this matrix multiplied by the vector X component, the second column by the vector Y component and the third column by the vector Z component. The matrix fourth column is unchanged.
func (*Mat4s) Set ¶
func (m *Mat4s) Set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 float32)
Set sets all the elements of this matrix row by row starting at row1, column1, row1, column2, row1, column3 and so forth.
func (*Mat4s) SetFrustum ¶
SetFrustum sets this matrix to a projection frustum matrix bounded by the specified planes.
func (*Mat4s) SetIdentity ¶
func (m *Mat4s) SetIdentity()
SetIdentity sets this matrix as the identity matrix.
func (*Mat4s) SetInverse ¶
SetInverse sets this matrix to the inverse of the src matrix. If the src matrix cannot be inverted returns error and sets this matrix to the identity matrix.
func (*Mat4s) SetOrthographic ¶
SetOrthographic sets this matrix to an orthographic projection matrix.
func (*Mat4s) SetPerspective ¶
SetPerspective sets this matrix to a perspective projection matrix with the specified field of view in degrees, aspect ratio (width/height) and near and far planes.
func (*Mat4s) SetPos ¶
SetPos sets this transformation matrix position fields from the specified vector v.
func (*Mat4s) SetRotationAxis ¶
SetRotationAxis sets this matrix to a rotation matrix of the specified angle around the specified axis.
func (*Mat4s) SetRotationFromEuler ¶
SetRotationFromEuler set this a matrix as a rotation matrix from the specified euler angles.
func (*Mat4s) SetRotationFromQuat ¶
SetRotationFromQuat sets this matrix as a rotation matrix from the specified quaternion.
func (*Mat4s) SetRotationX ¶
SetRotationX sets this matrix to a rotation matrix of angle theta around the X axis.
func (*Mat4s) SetRotationY ¶
SetRotationY sets this matrix to a rotation matrix of angle theta around the Y axis.
func (*Mat4s) SetRotationZ ¶
SetRotationZ sets this matrix to a rotation matrix of angle theta around the Z axis.
func (*Mat4s) SetScale ¶
SetScale sets this matrix to a scale transformation matrix using the specified x, y and z values.
func (*Mat4s) SetScaleCols ¶
SetScaleCols multiplies the first column of this matrix by the vector X component, the second column by the vector Y component and the third column by the vector Z component. The matrix fourth column is unchanged.
func (*Mat4s) SetTransform ¶
SetTransform sets this matrix to a transformation matrix for the specified position, rotation specified by the quaternion and scale.
func (*Mat4s) SetTranslation ¶
SetTranslation sets this matrix to a translation matrix from the specified x, y and z values.
func (*Mat4s) SetVkFrustum ¶
SetVkFrustum sets this matrix to a projection frustum matrix bounded by the specified planes. This version is for use with Vulkan, and does the equivalent of GLM_DEPTH_ZERO_ONE in glm and also multiplies the Y axis by -1, preserving the original OpenGL Y-up system. OpenGL provides a "natural" coordinate system for the physical world so it is useful to retain that for the world system and just convert on the way out to the render using this projection matrix.
func (*Mat4s) SetVkPerspective ¶
SetVkPerspective sets this matrix to a vulkan appropriate perspective projection matrix, assuming the use of the OpenGL Y-up coordinate system for the geometry points. OpenGL provides a "natural" coordinate system for the physical world so it is useful to retain that for the world system and just convert on the way out to the render using this projection matrix. The specified field of view is in degrees, aspect ratio (width/height) and near and far planes.
type Mesh ¶
type Mesh struct { Verts []float32 VC uint32 MaterialRef int Stride int BufRef int VertOffset int VertSize int Mode int }
func (*Mesh) AddPackedVert ¶
func (*Mesh) RenderIndexed ¶
func (*Mesh) RenderMesh ¶
func (m *Mesh) RenderMesh()
func (*Mesh) TransformVerts ¶
type Quat ¶
Quat is quaternion with X,Y,Z and W components.
func NewQuatAxisAngle ¶
NewQuatAxisAngle returns a new quaternion from given axis and angle rotation (radians).
func NewQuatEuler ¶
NewQuatEuler returns a new quaternion from given Euler angles.
func (*Quat) GenGoSet ¶
GenGoSet returns code to set values in object at given path (var.member etc)
func (*Quat) IsIdentity ¶
IsIdentity returns if this is an identity quaternion.
func (*Quat) NormalizeFast ¶
func (q *Quat) NormalizeFast()
NormalizeFast approximates normalizing this quaternion. Works best when the quaternion is already almost-normalized.
func (*Quat) SetConjugate ¶
func (q *Quat) SetConjugate()
SetConjugate sets this quaternion to its conjugate.
func (*Quat) SetFromAxisAngle ¶
SetFromAxisAngle sets this quaternion with the rotation specified by the given axis and angle.
func (*Quat) SetFromEuler ¶
SetFromEuler sets this quaternion from the specified vector with Euler angles for each axis. It is assumed that the Euler angles are in XYZ order.
func (*Quat) SetFromRotationMatrix ¶
SetFromRotationMatrix sets this quaternion from the specified rotation matrix.
func (*Quat) SetFromUnitVectors ¶
SetFromUnitVectors sets this quaternion to the rotation from vector vFrom to vTo. The vectors must be normalized.
func (*Quat) SetIdentity ¶
func (q *Quat) SetIdentity()
SetIdentity sets this quanternion to the identity quaternion.
func (*Quat) SetInverse ¶
func (q *Quat) SetInverse()
SetInverse sets this quaternion to its inverse.
func (*Quat) Slerp ¶
Slerp sets this quaternion to another quaternion which is the spherically linear interpolation from this quaternion to other using t.
func (*Quat) ToAxisAngle ¶
ToAxisAngle returns the Vec4 holding axis and angle of this Quaternion
type RenderBuffer ¶
type RenderBuffer struct { BufferID []uint32 Verts [][]float32 VertsPtr []int MaxBufSize uint32 CurrentBuffer int }
func (*RenderBuffer) Init ¶
func (b *RenderBuffer) Init()
func (*RenderBuffer) RemainingBuffer ¶
func (b *RenderBuffer) RemainingBuffer(bufRef int) int
type Scene ¶
type Scene struct { Width int32 Height int32 Textures map[string]uint32 Shapes map[string]*Shape Window *sdl.Window Context sdl.GLContext }
type ShaderSettings ¶
type ShaderSettings struct {
// contains filtered or unexported fields
}
func (*ShaderSettings) SetupShaderSettings ¶
func (settings *ShaderSettings) SetupShaderSettings(program uint32) []int32
type Shape ¶
type Shape struct { Name string ShapeType ShapeType Position Vec3 Rotation Vec3 Scale Vec3 Center Vec3 Colour uint32 Texture Texture W float32 H float32 D float32 Edges uint32 Path []Vec2 Verts []float32 Indexes []int Group []Shape }
func (*Shape) CreateCone ¶
func (*Shape) CreateCuboid ¶
func (*Shape) CreateCylinder ¶
func (*Shape) CreatePlane ¶
func (*Shape) CreateSphere ¶
func (*Shape) CreateSpring ¶
func (*Shape) CreateTCone ¶
func (*Shape) CreateTorus ¶
func (*Shape) CreateTube ¶
func (*Shape) DrawTriangles ¶
func (s *Shape) DrawTriangles()
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
func (*Texture) LoadTexture ¶
type UserInput ¶
func (*UserInput) GetUserInput ¶
func (ui *UserInput) GetUserInput()
type Vec2 ¶
func (Vec2) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (Vec2) WindowToNDC ¶
WindowToNDC converts window (pixel) coordinates to normalized display coordinates (NDC), using given window size parameters. The Z depth coordinate (0-1) must be set manually or by reading from framebuffer flipY if true means flip the Y axis (top = 0 for windows vs. bottom = 0 for 3D coords)
type Vec3 ¶
func NewEulerAnglesFromMatrix ¶
NewEulerAnglesFromMatrix returns a Vec3 with components as the Euler angles from the specified pure rotation matrix.
func (Vec3) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vec3) AlmostEqual ¶
AlmostEqual returns whether the vector is almost equal to another vector within the specified tolerance.
func (Vec3) AngleTo ¶
AngleTo returns the angle between this vector and other. Returns angles in range of -PI to PI (not 0 to 2 PI).
func (Vec3) Ceil ¶
Ceil returns vector with mat32.Ceil() applied to each of this vector's components.
func (*Vec3) Clamp ¶
Clamp sets this vector components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max, if this assumption isn't true it will not operate correctly.
func (*Vec3) ClampScalar ¶
ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.
func (Vec3) CosTo ¶
CosTo returns the cosine (normalized dot product) between this vector and other.
func (Vec3) DistToSquared ¶
DistToSquared returns the distance squared of this point to other.
func (Vec3) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vec3) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (Vec3) Floor ¶
Floor returns vector with mat32.Floor() applied to each of this vector's components.
func (Vec3) LengthSq ¶
LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.
func (Vec3) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vec3) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vec3) MulProjection ¶
MulProjection returns vector multiplied by the projection matrix m
func (Vec3) MulQuat ¶
MulQuat returns vector multiplied by specified quaternion and then by the quaternion inverse. It basically applies the rotation encoded in the quaternion to this vector.
func (Vec3) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (Vec3) NDCToWindow ¶
NDCToWindow converts normalized display coordinates (NDC) to window (pixel) coordinates, using given window size parameters. near, far are 0, 1 by default (glDepthRange defaults). flipY if true means flip the Y axis (top = 0 for windows vs. bottom = 0 for 3D coords)
func (*Vec3) Normalize ¶
func (v *Vec3) Normalize()
Normalize normalizes this vector so its length will be 1.
func (*Vec3) ProjectOnPlane ¶
ProjectOnPlane returns vector projected on the plane specified by normal vector.
func (*Vec3) ProjectOnVector ¶
ProjectOnVector returns vector projected on other vector.
func (*Vec3) RandomTangents ¶
RandomTangents computes and returns two arbitrary tangents to the vector.
func (*Vec3) Reflect ¶
Reflect returns vector reflected relative to the normal vector (assumed to be already normalized).
func (Vec3) RotateAxisAngle ¶
RotateAxisAngle returns vector rotated around axis by angle.
func (Vec3) Round ¶
Round returns vector with mat32.Round() applied to each of this vector's components.
func (*Vec3) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vec3) SetCeil ¶
func (v *Vec3) SetCeil()
SetCeil applies mat32.Ceil() to each of this vector's components.
func (*Vec3) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vec3) SetEulerAnglesFromMatrix ¶
SetEulerAnglesFromMatrix sets this vector components to the Euler angles from the specified pure rotation matrix.
func (*Vec3) SetEulerAnglesFromQuat ¶
SetEulerAnglesFromQuat sets this vector components to the Euler angles from the specified quaternion.
func (*Vec3) SetFloor ¶
func (v *Vec3) SetFloor()
SetFloor applies mat32.Floor() to each of this vector's components.
func (*Vec3) SetFromMatrixPos ¶
SetFromMatrixPos set this vector from the translation coordinates in the specified transformation matrix.
func (*Vec3) SetLength ¶
SetLength sets this vector to have the specified length. If the current length is zero, does nothing.
func (*Vec3) SetLerp ¶
SetLerp sets each of this vector's components to the linear interpolated value of alpha between itself and the corresponding other component.
func (*Vec3) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vec3) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vec3) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vec3) SetMulMat4 ¶
SetMulMat4 sets vector multiplied by specified 4x4 matrix.
func (*Vec3) SetMulQuat ¶
SetMulQuat multiplies vector by specified quaternion and then by the quaternion inverse. It basically applies the rotation encoded in the quaternion to this vector.
func (*Vec3) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vec3) SetNegate ¶
func (v *Vec3) SetNegate()
SetNegate negates each of this vector's components.
func (*Vec3) SetNormal ¶
func (v *Vec3) SetNormal()
SetNormal normalizes this vector so its length will be 1.
func (*Vec3) SetRotateAxisAngle ¶
SetRotateAxisAngle sets vector rotated around axis by angle.
func (*Vec3) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vec3) SetZero ¶
func (v *Vec3) SetZero()
SetZero sets this vector X, Y and Z components to be zero.
type Vec4 ¶
Vec4 is a vector/point in homogeneous coordinates with X, Y, Z and W components.
func (Vec4) AddScalar ¶
AddScalar adds scalar s to each component of this vector and returns new vector.
func (*Vec4) AlmostEqual ¶
AlmostEqual returns whether the vector is almost equal to another vector within the specified tolerance.
func (Vec4) Ceil ¶
Ceil returns vector with mat32.Ceil() applied to each of this vector's components.
func (*Vec4) Clamp ¶
Clamp sets this vector components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max, if this assumption isn't true it will not operate correctly.
func (*Vec4) ClampScalar ¶
ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.
func (Vec4) Div ¶
Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.
func (Vec4) DivScalar ¶
DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.
func (Vec4) Floor ¶
Floor returns vector with mat32.Floor() applied to each of this vector's components.
func (*Vec4) FromArray ¶
FromArray sets this vector's components from the specified array and offset
func (Vec4) LengthSq ¶
LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.
func (Vec4) Lerp ¶
Lerp returns vector with each components as the linear interpolated value of alpha between itself and the corresponding other component.
func (Vec4) Mul ¶
Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.
func (Vec4) MulScalar ¶
MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.
func (*Vec4) Normalize ¶
func (v *Vec4) Normalize()
Normalize normalizes this vector so its length will be 1.
func (Vec4) PerspDiv ¶
PerspDiv returns the 3-vector of normalized display coordinates (NDC) from given 4-vector By dividing by the 4th W component
func (Vec4) Round ¶
Round returns vector with mat32.Round() applied to each of this vector's components.
func (*Vec4) SetAddScalar ¶
SetAddScalar sets this to addition with scalar.
func (*Vec4) SetAxisAngleFromQuat ¶
SetAxisAngleFromQuat set this vector to be the axis (x, y, z) and angle (w) of a rotation specified the quaternion q. Assumes q is normalized.
func (*Vec4) SetAxisFromRotationMatrix ¶
SetAxisFromRotationMatrix sets this vector to be the axis (x, y, z) and angle (w) of a rotation specified the matrix m. Assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).
func (*Vec4) SetByName ¶
SetByName sets this vector component value by its case insensitive name: "x", "y", "z" or "w".
func (*Vec4) SetCeil ¶
func (v *Vec4) SetCeil()
SetCeil applies mat32.Ceil() to each of this vector's components.
func (*Vec4) SetDivScalar ¶
SetDivScalar sets this to division by scalar.
func (*Vec4) SetFloor ¶
func (v *Vec4) SetFloor()
SetFloor applies mat32.Floor() to each of this vector's components.
func (*Vec4) SetFromVec2 ¶
SetFromVec2 sets this vector from a Vec2 with 0,1 for Z,W
func (*Vec4) SetFromVec3 ¶
SetFromVec3 sets this vector from a Vec3 and W
func (*Vec4) SetLength ¶
SetLength sets this vector to have the specified length. If the current length is zero, does nothing.
func (*Vec4) SetLerp ¶
SetLerp sets each of this vector's components to the linear interpolated value of alpha between ifself and the corresponding other component.
func (*Vec4) SetMax ¶
SetMax sets this vector components to the maximum value of itself and other vector.
func (*Vec4) SetMin ¶
SetMin sets this vector components to the minimum values of itself and other vector.
func (*Vec4) SetMul ¶
SetMul sets this to multiplication with other vector (i.e., *= or times-equals).
func (*Vec4) SetMulScalar ¶
SetMulScalar sets this to multiplication by scalar.
func (*Vec4) SetNegate ¶
func (v *Vec4) SetNegate()
SetNegate negates each of this vector's components.
func (*Vec4) SetNormal ¶
func (v *Vec4) SetNormal()
SetNormal normalizes this vector so its length will be 1.
func (*Vec4) SetSubScalar ¶
SetSubScalar sets this to subtraction of scalar.
func (*Vec4) SetZero ¶
func (v *Vec4) SetZero()
SetZero sets this vector X, Y and Z components to be zero and W to be one.