Package limn.math
Record Class Vec2
java.lang.Object
java.lang.Record
limn.math.Vec2
An immutable 2-component vector (single precision): texture coords, screen points.
The arithmetic is component-wise; normalize() is the only operation with an edge
case.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.floatlength()floatmul(float s) Unit vector in the same direction; returnsZEROfor a zero-length input.final StringtoString()Returns a string representation of this record class.floatx()Returns the value of thexrecord component.floaty()Returns the value of theyrecord component.
-
Field Details
-
ZERO
Both components zero. -
ONE
Both components one.
-
-
Constructor Details
-
Vec2
public Vec2(float x, float y) Creates an instance of aVec2record class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord component
-
-
Method Details
-
add
- Returns:
- the sum of this vector and
o
-
sub
- Returns:
- this vector minus
o
-
mul
- Returns:
- this vector scaled by
s
-
dot
- Returns:
- the dot product of this vector and
o
-
lengthSquared
public float lengthSquared()- Returns:
- the squared length, which needs no square root
-
length
public float length()- Returns:
- the Euclidean length
-
normalize
Unit vector in the same direction; returnsZEROfor a zero-length input. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
x
public float x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public float y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-