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 and unsurprising; normalize() is the only
operation with an edge case worth stating.
-
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
-
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
-
sub
-
mul
-
dot
-
lengthSquared
public float lengthSquared() -
length
public float 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
-