Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- getAcceleration(double, double)
- getTerminalVelocity(double, double, double, double)
- getRelativeDensity(Vector3d, Box)
- computeDragCoefficient(double, double, double, double)
- computeTerminalSpeed(double, double, double, double)
- computeProjectedArea(double, double, double, Box)
- computeProjectedArea(Vector3d, Box)
- volumeOfIntersection(Box, Vector3dc, Box, Vector3dc)
- volumeOfIntersection(Box, Vector3dc, Box, double, double, double)
- lengthOfIntersection(double, double, double, double)
- headingFromDirection(double, double)
- normalizeAngle(float)
- normalizeTurnAngle(float)
- pitchFromDirection(double, double, double)
- vectorFromAngles(float, float, Vector3d)
- pitchX(float)
- pitchY(float)
- headingX(float)
- headingZ(float)
Class PhysicsMath
java.lang.Object
com.hypixel.hytale.server.core.modules.physics.util.PhysicsMath
- Since:
- 02/05/2019
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublestatic final doublestatic final doublestatic final float -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecomputeDragCoefficient(double terminalSpeed, double area, double mass, double gravity) Compute drag coefficient from terminal speed when falling in air.static doublecomputeProjectedArea(double x, double y, double z, Box box) Compute area of projection of box onto plane with normal given by direction vectorstatic doublecomputeProjectedArea(org.joml.Vector3d direction, Box box) Compute area of projection of box onto plane with normal given by direction vectorstatic doublecomputeTerminalSpeed(double dragCoefficient, double area, double mass, double gravity) Compute terminal speed from drag coefficient when falling in air.static doublegetAcceleration(double speed, double terminalSpeed) static doublegetRelativeDensity(org.joml.Vector3d position, Box boundingBox) static doublegetTerminalVelocity(double mass, double density, double areaMillimetersSquared, double dragCoefficient) static floatheadingFromDirection(double x, double z) Get heading from x/z directional vector using game coordinate system.static floatheadingX(float heading) Compute x component of vector in direction heading.static floatheadingZ(float heading) Compute z component of vector in direction heading.static doublelengthOfIntersection(double aMin, double aMax, double bMin, double bMax) Compute length of overlap of two intervals.static floatnormalizeAngle(float rad) Convert angle to [0..2*PI[static floatnormalizeTurnAngle(float rad) Convert angle to [-PI..PI[static floatpitchFromDirection(double x, double y, double z) Return pitch from x/y/z direction vector using game coordinate system.static floatpitchX(float pitch) Compute x component of vector with given pitch.static floatpitchY(float pitch) Compute y component of vector with given pitch.static org.joml.Vector3dvectorFromAngles(float heading, float pitch, org.joml.Vector3d outDirection) Calculate a directional (not necessarily normalized) vector from heading and pitch.static doublevolumeOfIntersection(Box a, org.joml.Vector3dc posA, Box b, double posBX, double posBY, double posBZ) Compute volume of intersection between to boxes.static doublevolumeOfIntersection(Box a, org.joml.Vector3dc posA, Box b, org.joml.Vector3dc posB) Compute volume of intersection between to boxes.
-
Field Details
-
DENSITY_AIR
public static final double DENSITY_AIR- See Also:
-
DENSITY_WATER
public static final double DENSITY_WATER- See Also:
-
AIR_DENSITY
public static final double AIR_DENSITY- See Also:
-
HEADING_DIRECTION
public static final float HEADING_DIRECTION- See Also:
-
-
Constructor Details
-
PhysicsMath
public PhysicsMath()
-
-
Method Details
-
getAcceleration
public static double getAcceleration(double speed, double terminalSpeed) -
getTerminalVelocity
public static double getTerminalVelocity(double mass, double density, double areaMillimetersSquared, double dragCoefficient) -
getRelativeDensity
-
computeDragCoefficient
public static double computeDragCoefficient(double terminalSpeed, double area, double mass, double gravity) Compute drag coefficient from terminal speed when falling in air.- Parameters:
terminalSpeed- Desired terminal speed when fallingarea- Area of projection of body along movement directionmass- Mass of bodygravity- Gravity of world- Returns:
- Drag value so that gravity force and drag force will be in balance when reaching terminal speed
-
computeTerminalSpeed
public static double computeTerminalSpeed(double dragCoefficient, double area, double mass, double gravity) Compute terminal speed from drag coefficient when falling in air.- Parameters:
dragCoefficient- Drag coefficientarea- Area of projection of body along movement directionmass- Mass of bodygravity- Gravity of world- Returns:
- Speed when gravity force and drag force are in balance
-
computeProjectedArea
Compute area of projection of box onto plane with normal given by direction vector- Parameters:
x- Projection direction xy- Projection direction yz- Projection direction zbox- Box to be projected- Returns:
- Area of projected cuboid onto plane with normal given by x/y/z. if x/y/z isn't normalized result must be divided by length of vector
-
computeProjectedArea
Compute area of projection of box onto plane with normal given by direction vector- Parameters:
direction- Projection directionbox- Box to be projected- Returns:
- Area of projected box onto plane with normal given by direction. if direction isn't normalized result must be divided by length of vector
-
volumeOfIntersection
public static double volumeOfIntersection(@Nonnull Box a, @Nonnull org.joml.Vector3dc posA, @Nonnull Box b, @Nonnull org.joml.Vector3dc posB) Compute volume of intersection between to boxes.- Parameters:
a- BoxposA- Position of box ab- Other boxposB- Position of box b- Returns:
- Volume of intersection of the two boxes or 0 if no intersection
-
volumeOfIntersection
public static double volumeOfIntersection(@Nonnull Box a, @Nonnull org.joml.Vector3dc posA, @Nonnull Box b, double posBX, double posBY, double posBZ) Compute volume of intersection between to boxes.- Parameters:
a- BoxposA- Position of box ab- Other boxposBX- X coordinate of box bposBY- Y coordinate of box bposBZ- Z coordinate of box b- Returns:
- Volume of intersection of the two boxes or 0 if no intersection
-
lengthOfIntersection
public static double lengthOfIntersection(double aMin, double aMax, double bMin, double bMax) Compute length of overlap of two intervals.- Parameters:
aMin- Start of first intervalaMax- End of first interval (must be greater equal start)bMin- Start of second intervalbMax- End of second interval (must be greater equal start)- Returns:
- Length of overlapping segment or 0 if no overlap
-
headingFromDirection
public static float headingFromDirection(double x, double z) Get heading from x/z directional vector using game coordinate system.- Parameters:
x- x component of directionz- z component of direction- Returns:
- heading in radians
-
normalizeAngle
public static float normalizeAngle(float rad) Convert angle to [0..2*PI[- Parameters:
rad- angle in radian- Returns:
- angle in range [0..2*PI[
-
normalizeTurnAngle
public static float normalizeTurnAngle(float rad) Convert angle to [-PI..PI[- Parameters:
rad- angle in radian- Returns:
- angle in range [-PI..PI[
-
pitchFromDirection
public static float pitchFromDirection(double x, double y, double z) Return pitch from x/y/z direction vector using game coordinate system.- Parameters:
x- x component of directiony- y component of directionz- z component of direction- Returns:
- pitch in radians
-
vectorFromAngles
@Nonnull public static org.joml.Vector3d vectorFromAngles(float heading, float pitch, @Nonnull org.joml.Vector3d outDirection) Calculate a directional (not necessarily normalized) vector from heading and pitch.- Parameters:
heading- in radians (game angles)pitch- in radians (game angles)outDirection- vector to be filled in- Returns:
- outDirection vector
-
pitchX
public static float pitchX(float pitch) Compute x component of vector with given pitch.- Parameters:
pitch- Angle- Returns:
- Equivalent of cos(pitch)
-
pitchY
public static float pitchY(float pitch) Compute y component of vector with given pitch.- Parameters:
pitch- Angle- Returns:
- Equivalent of sin(heading)
-
headingX
public static float headingX(float heading) Compute x component of vector in direction heading.- Parameters:
heading- Angle- Returns:
- Equivalent of cos(heading)
-
headingZ
public static float headingZ(float heading) Compute z component of vector in direction heading.- Parameters:
heading- Angle- Returns:
- Equivalent of sin(heading)
-