Class Vec3d
- All Implemented Interfaces:
Position
This vector class is used for representing position, velocity, rotation, color, etc.
This vector has proper hashCode() and equals(Object)
implementations and can be used as a map key.
- See Also:
- Mappings:
Namespace Name official eeaintermediary net/minecraft/class_243named net/minecraft/util/math/Vec3d
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double x, double y, double z) Returns the sum of this vector and the given vector.Returns the sum of this vector and the given vector.static Vec3dReturns a new vector fromvecwithdeltaX,deltaY, anddeltaZadded to X, Y, Z values, respectively.Returns a vector with each value added byrandom.nextFloat() - 0.5f) * multiplier.crossProduct(Vec3d vec) Returns the cross product of this vector and the given vector.doubledistanceTo(Vec3d vec) Returns the distance between this vector and the given vector.doubledotProduct(Vec3d vec) Returns the dot product of this vector and the given vector.booleanfloorAlongAxes(EnumSet<Direction.Axis> axes) Applies the floor function to the coordinates chosen by the given axes.static Vec3dfromPolar(float pitch, float yaw) Converts pitch and yaw into a direction vector.static Vec3dConverts pitch and yaw into a direction vector.doubleReturns the coordinate chosen by the given axis.final doublegetX()Returns the X coordinate.final doublegetY()Returns the Y coordinate.final doublegetZ()Returns the Z coordinate.inthashCode()doubleReturns the horizontal length of this vector.doubleReturns the squared horizontal length of this vector.booleanChecks if the distance between this vector and the given position is less thanradius.doublelength()Returns the length of this vector.doubleReturns the squared length of this vector.Performs linear interpolation from this vector to the given vector.multiply(double value) Return a vector whose coordinates are the coordinates of this vector each multiplied by the given scalar value.multiply(double x, double y, double z) Returns a vector whose coordinates are the product of each pair of coordinates in this vector and the given vector.Returns a vector whose coordinates are the product of each pair of coordinates in this vector and the given vector.negate()Creates a vector with the same length but with the opposite direction.Normalizes this vector.static Vec3dCopies the given vector.static Vec3dofBottomCenter(Vec3i vec) Creates a vector representing the bottom center of the given block position.static Vec3dCreates a vector representing the center of the given block position.static Vec3dCreates a vector representing the center of the given block position but with the given offset for the Y coordinate.relativize(Vec3d vec) Subtracts this vector from the given vector.rotateX(float angle) Rotates this vector by the given angle counterclockwise around the X axis.rotateY(float angle) Rotates this vector by the given angle counterclockwise around the Y axis.rotateZ(float angle) Rotates this vector by the given angle counterclockwise around the Z axis.doublesquaredDistanceTo(double x, double y, double z) Returns the squared distance between this vector and the given vector.doublesquaredDistanceTo(Vec3d vec) Returns the squared distance between this vector and the given vector.subtract(double x, double y, double z) Subtracts the given vector from this vector.Subtracts the given vector from this vector.toString()Returns a JOMLVector3frepresenting this vector.static Vec3dunpackRgb(int rgb) Converts a packed RGB color into a vector of (red, green, blue).withAxis(Direction.Axis axis, double value)
-
Field Details
-
CODEC
- Mappings:
Namespace Name Mixin selector official aLeea;a:Lcom/mojang/serialization/Codec;intermediary field_38277Lnet/minecraft/class_243;field_38277:Lcom/mojang/serialization/Codec;named CODECLnet/minecraft/util/math/Vec3d;CODEC:Lcom/mojang/serialization/Codec;
-
ZERO
The zero vector (0, 0, 0).- Mappings:
Namespace Name Mixin selector official bLeea;b:Leea;intermediary field_1353Lnet/minecraft/class_243;field_1353:Lnet/minecraft/class_243;named ZEROLnet/minecraft/util/math/Vec3d;ZERO:Lnet/minecraft/util/math/Vec3d;
-
x
public final double xThe X coordinate of this vector.- Mappings:
Namespace Name Mixin selector official cLeea;c:Dintermediary field_1352Lnet/minecraft/class_243;field_1352:Dnamed xLnet/minecraft/util/math/Vec3d;x:D
-
y
public final double yThe Y coordinate of this vector.- Mappings:
Namespace Name Mixin selector official dLeea;d:Dintermediary field_1351Lnet/minecraft/class_243;field_1351:Dnamed yLnet/minecraft/util/math/Vec3d;y:D
-
z
public final double zThe Z coordinate of this vector.- Mappings:
Namespace Name Mixin selector official eLeea;e:Dintermediary field_1350Lnet/minecraft/class_243;field_1350:Dnamed zLnet/minecraft/util/math/Vec3d;z:D
-
-
Constructor Details
-
Vec3d
public Vec3d(double x, double y, double z) Creates a vector of the given coordinates.- Mappings:
Namespace Name Mixin selector official <init>Leea;<init>(DDD)Vintermediary <init>Lnet/minecraft/class_243;<init>(DDD)Vnamed <init>Lnet/minecraft/util/math/Vec3d;<init>(DDD)V
-
Vec3d
Copies the given vector.- Mappings:
Namespace Name Mixin selector official <init>Leea;<init>(Lorg/joml/Vector3f;)Vintermediary <init>Lnet/minecraft/class_243;<init>(Lorg/joml/Vector3f;)Vnamed <init>Lnet/minecraft/util/math/Vec3d;<init>(Lorg/joml/Vector3f;)V
-
-
Method Details
-
unpackRgb
Converts a packed RGB color into a vector of (red, green, blue).- Parameters:
rgb- the color in the 0xRRGGBB format- Returns:
- the vector representing the given color; each coordinate has value between 0 and 1
- Mappings:
Namespace Name Mixin selector official aLeea;a(I)Leea;intermediary method_24457Lnet/minecraft/class_243;method_24457(I)Lnet/minecraft/class_243;named unpackRgbLnet/minecraft/util/math/Vec3d;unpackRgb(I)Lnet/minecraft/util/math/Vec3d;
-
of
Copies the given vector.- Mappings:
Namespace Name Mixin selector official aLeea;a(Lhz;)Leea;intermediary method_24954Lnet/minecraft/class_243;method_24954(Lnet/minecraft/class_2382;)Lnet/minecraft/class_243;named ofLnet/minecraft/util/math/Vec3d;of(Lnet/minecraft/util/math/Vec3i;)Lnet/minecraft/util/math/Vec3d;
-
add
Returns a new vector fromvecwithdeltaX,deltaY, anddeltaZadded to X, Y, Z values, respectively.- Returns:
- a new vector from
vecwithdeltaX,deltaY, anddeltaZadded to X, Y, Z values, respectively - Mappings:
Namespace Name Mixin selector official aLeea;a(Lhz;DDD)Leea;intermediary method_49273Lnet/minecraft/class_243;method_49273(Lnet/minecraft/class_2382;DDD)Lnet/minecraft/class_243;named addLnet/minecraft/util/math/Vec3d;add(Lnet/minecraft/util/math/Vec3i;DDD)Lnet/minecraft/util/math/Vec3d;
-
ofCenter
Creates a vector representing the center of the given block position.- Mappings:
Namespace Name Mixin selector official bLeea;b(Lhz;)Leea;intermediary method_24953Lnet/minecraft/class_243;method_24953(Lnet/minecraft/class_2382;)Lnet/minecraft/class_243;named ofCenterLnet/minecraft/util/math/Vec3d;ofCenter(Lnet/minecraft/util/math/Vec3i;)Lnet/minecraft/util/math/Vec3d;
-
ofBottomCenter
Creates a vector representing the bottom center of the given block position.The bottom center of a block position
posis(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5).- See Also:
- Mappings:
Namespace Name Mixin selector official cLeea;c(Lhz;)Leea;intermediary method_24955Lnet/minecraft/class_243;method_24955(Lnet/minecraft/class_2382;)Lnet/minecraft/class_243;named ofBottomCenterLnet/minecraft/util/math/Vec3d;ofBottomCenter(Lnet/minecraft/util/math/Vec3i;)Lnet/minecraft/util/math/Vec3d;
-
ofCenter
Creates a vector representing the center of the given block position but with the given offset for the Y coordinate.- Returns:
- a vector of
(vec.getX() + 0.5, vec.getY() + deltaY, vec.getZ() + 0.5) - Mappings:
Namespace Name Mixin selector official aLeea;a(Lhz;D)Leea;intermediary method_26410Lnet/minecraft/class_243;method_26410(Lnet/minecraft/class_2382;D)Lnet/minecraft/class_243;named ofCenterLnet/minecraft/util/math/Vec3d;ofCenter(Lnet/minecraft/util/math/Vec3i;D)Lnet/minecraft/util/math/Vec3d;
-
relativize
Subtracts this vector from the given vector.- Returns:
- the difference between the given vector and this vector
- See Also:
- Mappings:
Namespace Name Mixin selector official aLeea;a(Leea;)Leea;intermediary method_1035Lnet/minecraft/class_243;method_1035(Lnet/minecraft/class_243;)Lnet/minecraft/class_243;named relativizeLnet/minecraft/util/math/Vec3d;relativize(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;
-
normalize
Normalizes this vector.Normalized vector is a vector with the same direction but with length 1. Each coordinate of normalized vector has value between 0 and 1.
- Returns:
- the normalized vector of this vector
- Mappings:
Namespace Name Mixin selector official dLeea;d()Leea;intermediary method_1029Lnet/minecraft/class_243;method_1029()Lnet/minecraft/class_243;named normalizeLnet/minecraft/util/math/Vec3d;normalize()Lnet/minecraft/util/math/Vec3d;
-
dotProduct
Returns the dot product of this vector and the given vector.- Mappings:
Namespace Name Mixin selector official bLeea;b(Leea;)Dintermediary method_1026Lnet/minecraft/class_243;method_1026(Lnet/minecraft/class_243;)Dnamed dotProductLnet/minecraft/util/math/Vec3d;dotProduct(Lnet/minecraft/util/math/Vec3d;)D
-
crossProduct
Returns the cross product of this vector and the given vector.- Mappings:
Namespace Name Mixin selector official cLeea;c(Leea;)Leea;intermediary method_1036Lnet/minecraft/class_243;method_1036(Lnet/minecraft/class_243;)Lnet/minecraft/class_243;named crossProductLnet/minecraft/util/math/Vec3d;crossProduct(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;
-
subtract
Subtracts the given vector from this vector.- Returns:
- the difference between this vector and the given vector
- See Also:
- Mappings:
Namespace Name Mixin selector official dLeea;d(Leea;)Leea;intermediary method_1020Lnet/minecraft/class_243;method_1020(Lnet/minecraft/class_243;)Lnet/minecraft/class_243;named subtractLnet/minecraft/util/math/Vec3d;subtract(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;
-
subtract
Subtracts the given vector from this vector.- Returns:
- the difference between this vector and the given vector
- See Also:
- Mappings:
Namespace Name Mixin selector official aLeea;a(DDD)Leea;intermediary method_1023Lnet/minecraft/class_243;method_1023(DDD)Lnet/minecraft/class_243;named subtractLnet/minecraft/util/math/Vec3d;subtract(DDD)Lnet/minecraft/util/math/Vec3d;
-
add
Returns the sum of this vector and the given vector.- See Also:
- Mappings:
Namespace Name Mixin selector official eLeea;e(Leea;)Leea;intermediary method_1019Lnet/minecraft/class_243;method_1019(Lnet/minecraft/class_243;)Lnet/minecraft/class_243;named addLnet/minecraft/util/math/Vec3d;add(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;
-
add
Returns the sum of this vector and the given vector.- See Also:
- Mappings:
Namespace Name Mixin selector official bLeea;b(DDD)Leea;intermediary method_1031Lnet/minecraft/class_243;method_1031(DDD)Lnet/minecraft/class_243;named addLnet/minecraft/util/math/Vec3d;add(DDD)Lnet/minecraft/util/math/Vec3d;
-
isInRange
Checks if the distance between this vector and the given position is less thanradius.- Mappings:
Namespace Name Mixin selector official aLeea;a(Lho;D)Zintermediary method_24802Lnet/minecraft/class_243;method_24802(Lnet/minecraft/class_2374;D)Znamed isInRangeLnet/minecraft/util/math/Vec3d;isInRange(Lnet/minecraft/util/math/Position;D)Z
-
distanceTo
Returns the distance between this vector and the given vector.- See Also:
- Mappings:
Namespace Name Mixin selector official fLeea;f(Leea;)Dintermediary method_1022Lnet/minecraft/class_243;method_1022(Lnet/minecraft/class_243;)Dnamed distanceToLnet/minecraft/util/math/Vec3d;distanceTo(Lnet/minecraft/util/math/Vec3d;)D
-
squaredDistanceTo
Returns the squared distance between this vector and the given vector.Can be used for fast comparison between distances.
- See Also:
- Mappings:
Namespace Name Mixin selector official gLeea;g(Leea;)Dintermediary method_1025Lnet/minecraft/class_243;method_1025(Lnet/minecraft/class_243;)Dnamed squaredDistanceToLnet/minecraft/util/math/Vec3d;squaredDistanceTo(Lnet/minecraft/util/math/Vec3d;)D
-
squaredDistanceTo
public double squaredDistanceTo(double x, double y, double z) Returns the squared distance between this vector and the given vector.Can be used for fast comparison between distances.
- See Also:
- Mappings:
Namespace Name Mixin selector official cLeea;c(DDD)Dintermediary method_1028Lnet/minecraft/class_243;method_1028(DDD)Dnamed squaredDistanceToLnet/minecraft/util/math/Vec3d;squaredDistanceTo(DDD)D
-
multiply
Return a vector whose coordinates are the coordinates of this vector each multiplied by the given scalar value.- See Also:
- Mappings:
Namespace Name Mixin selector official aLeea;a(D)Leea;intermediary method_1021Lnet/minecraft/class_243;method_1021(D)Lnet/minecraft/class_243;named multiplyLnet/minecraft/util/math/Vec3d;multiply(D)Lnet/minecraft/util/math/Vec3d;
-
negate
Creates a vector with the same length but with the opposite direction.- Mappings:
Namespace Name Mixin selector official eLeea;e()Leea;intermediary method_22882Lnet/minecraft/class_243;method_22882()Lnet/minecraft/class_243;named negateLnet/minecraft/util/math/Vec3d;negate()Lnet/minecraft/util/math/Vec3d;
-
multiply
Returns a vector whose coordinates are the product of each pair of coordinates in this vector and the given vector.- See Also:
- Mappings:
Namespace Name Mixin selector official hLeea;h(Leea;)Leea;intermediary method_18806Lnet/minecraft/class_243;method_18806(Lnet/minecraft/class_243;)Lnet/minecraft/class_243;named multiplyLnet/minecraft/util/math/Vec3d;multiply(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;
-
multiply
Returns a vector whose coordinates are the product of each pair of coordinates in this vector and the given vector.- See Also:
- Mappings:
Namespace Name Mixin selector official dLeea;d(DDD)Leea;intermediary method_18805Lnet/minecraft/class_243;method_18805(DDD)Lnet/minecraft/class_243;named multiplyLnet/minecraft/util/math/Vec3d;multiply(DDD)Lnet/minecraft/util/math/Vec3d;
-
addRandom
Returns a vector with each value added byrandom.nextFloat() - 0.5f) * multiplier.- Returns:
- a vector with each value added by
random.nextFloat() - 0.5f) * multiplier - Mappings:
Namespace Name Mixin selector official aLeea;a(Lapf;F)Leea;intermediary method_49272Lnet/minecraft/class_243;method_49272(Lnet/minecraft/class_5819;F)Lnet/minecraft/class_243;named addRandomLnet/minecraft/util/math/Vec3d;addRandom(Lnet/minecraft/util/math/random/Random;F)Lnet/minecraft/util/math/Vec3d;
-
length
public double length()Returns the length of this vector.The length of a vector is equivalent to the distance between that vector and the ZERO vector.
- Returns:
- the length of this vector
- See Also:
- Mappings:
Namespace Name Mixin selector official fLeea;f()Dintermediary method_1033Lnet/minecraft/class_243;method_1033()Dnamed lengthLnet/minecraft/util/math/Vec3d;length()D
-
lengthSquared
public double lengthSquared()Returns the squared length of this vector.Can be used for fast comparison between lengths.
- Returns:
- the squared length of this vector
- See Also:
- Mappings:
Namespace Name Mixin selector official gLeea;g()Dintermediary method_1027Lnet/minecraft/class_243;method_1027()Dnamed lengthSquaredLnet/minecraft/util/math/Vec3d;lengthSquared()D
-
horizontalLength
public double horizontalLength()Returns the horizontal length of this vector.This length is same as the length of a 2-vector with the
xandzcomponents of this vector, or the euclidean distance between(x, z)and the origin.- Returns:
- the horizontal length of this vector
- See Also:
- Mappings:
Namespace Name Mixin selector official hLeea;h()Dintermediary method_37267Lnet/minecraft/class_243;method_37267()Dnamed horizontalLengthLnet/minecraft/util/math/Vec3d;horizontalLength()D
-
horizontalLengthSquared
public double horizontalLengthSquared()Returns the squared horizontal length of this vector.Can be used for fast comparison between horizontal lengths.
- Returns:
- the squared horizontal length of this vector
- See Also:
- Mappings:
Namespace Name Mixin selector official iLeea;i()Dintermediary method_37268Lnet/minecraft/class_243;method_37268()Dnamed horizontalLengthSquaredLnet/minecraft/util/math/Vec3d;horizontalLengthSquared()D
-
equals
-
hashCode
public int hashCode() -
toString
-
lerp
Performs linear interpolation from this vector to the given vector.- Parameters:
to- the vector to interpolate todelta- the interpolation coefficient in the range between 0 and 1- Mappings:
Namespace Name Mixin selector official aLeea;a(Leea;D)Leea;intermediary method_35590Lnet/minecraft/class_243;method_35590(Lnet/minecraft/class_243;D)Lnet/minecraft/class_243;named lerpLnet/minecraft/util/math/Vec3d;lerp(Lnet/minecraft/util/math/Vec3d;D)Lnet/minecraft/util/math/Vec3d;
-
rotateX
Rotates this vector by the given angle counterclockwise around the X axis.- Parameters:
angle- the angle in radians- Mappings:
Namespace Name Mixin selector official aLeea;a(F)Leea;intermediary method_1037Lnet/minecraft/class_243;method_1037(F)Lnet/minecraft/class_243;named rotateXLnet/minecraft/util/math/Vec3d;rotateX(F)Lnet/minecraft/util/math/Vec3d;
-
rotateY
Rotates this vector by the given angle counterclockwise around the Y axis.- Parameters:
angle- the angle in radians- Mappings:
Namespace Name Mixin selector official bLeea;b(F)Leea;intermediary method_1024Lnet/minecraft/class_243;method_1024(F)Lnet/minecraft/class_243;named rotateYLnet/minecraft/util/math/Vec3d;rotateY(F)Lnet/minecraft/util/math/Vec3d;
-
rotateZ
Rotates this vector by the given angle counterclockwise around the Z axis.- Parameters:
angle- the angle in radians- Mappings:
Namespace Name Mixin selector official cLeea;c(F)Leea;intermediary method_31033Lnet/minecraft/class_243;method_31033(F)Lnet/minecraft/class_243;named rotateZLnet/minecraft/util/math/Vec3d;rotateZ(F)Lnet/minecraft/util/math/Vec3d;
-
fromPolar
Converts pitch and yaw into a direction vector.- Parameters:
polar- the vector composed of pitch and yaw- See Also:
- Mappings:
Namespace Name Mixin selector official aLeea;a(Ledz;)Leea;intermediary method_1034Lnet/minecraft/class_243;method_1034(Lnet/minecraft/class_241;)Lnet/minecraft/class_243;named fromPolarLnet/minecraft/util/math/Vec3d;fromPolar(Lnet/minecraft/util/math/Vec2f;)Lnet/minecraft/util/math/Vec3d;
-
fromPolar
Converts pitch and yaw into a direction vector.- See Also:
- Mappings:
Namespace Name Mixin selector official aLeea;a(FF)Leea;intermediary method_1030Lnet/minecraft/class_243;method_1030(FF)Lnet/minecraft/class_243;named fromPolarLnet/minecraft/util/math/Vec3d;fromPolar(FF)Lnet/minecraft/util/math/Vec3d;
-
floorAlongAxes
Applies the floor function to the coordinates chosen by the given axes.- Mappings:
Namespace Name Mixin selector official aLeea;a(Ljava/util/EnumSet;)Leea;intermediary method_1032Lnet/minecraft/class_243;method_1032(Ljava/util/EnumSet;)Lnet/minecraft/class_243;named floorAlongAxesLnet/minecraft/util/math/Vec3d;floorAlongAxes(Ljava/util/EnumSet;)Lnet/minecraft/util/math/Vec3d;
-
getComponentAlongAxis
Returns the coordinate chosen by the given axis.- Mappings:
Namespace Name Mixin selector official aLeea;a(Lha$a;)Dintermediary method_18043Lnet/minecraft/class_243;method_18043(Lnet/minecraft/class_2350$class_2351;)Dnamed getComponentAlongAxisLnet/minecraft/util/math/Vec3d;getComponentAlongAxis(Lnet/minecraft/util/math/Direction$Axis;)D
-
withAxis
- Mappings:
Namespace Name Mixin selector official aLeea;a(Lha$a;D)Leea;intermediary method_38499Lnet/minecraft/class_243;method_38499(Lnet/minecraft/class_2350$class_2351;D)Lnet/minecraft/class_243;named withAxisLnet/minecraft/util/math/Vec3d;withAxis(Lnet/minecraft/util/math/Direction$Axis;D)Lnet/minecraft/util/math/Vec3d;
-
offset
- Mappings:
Namespace Name Mixin selector official aLeea;a(Lha;D)Leea;intermediary method_43206Lnet/minecraft/class_243;method_43206(Lnet/minecraft/class_2350;D)Lnet/minecraft/class_243;named offsetLnet/minecraft/util/math/Vec3d;offset(Lnet/minecraft/util/math/Direction;D)Lnet/minecraft/util/math/Vec3d;
-
getX
public final double getX()Returns the X coordinate. -
getY
public final double getY()Returns the Y coordinate. -
getZ
public final double getZ()Returns the Z coordinate. -
toVector3f
Returns a JOMLVector3frepresenting this vector.- Returns:
- a JOML
Vector3frepresenting this vector - Mappings:
Namespace Name Mixin selector official jLeea;j()Lorg/joml/Vector3f;intermediary method_46409Lnet/minecraft/class_243;method_46409()Lorg/joml/Vector3f;named toVector3fLnet/minecraft/util/math/Vec3d;toVector3f()Lorg/joml/Vector3f;
-