Class: Phyiscs

Phyiscs(simulator)

Represents the physics simulation for a submarine within an environment. Manages the dynamics and forces acting on the submarine.

Constructor

new Phyiscs(simulator)

Constructs an instance of the Physics class. Initializes necessary attributes and subscribes to submarine state changes.
Parameters:
Name Type Description
simulator Simulator The simulator instance managing the environment.
Source:

Methods

calculatePlaneForce(coefficient, area, angle) → {number}

Calculates the force acting on a plane surface based on coefficient, area, and angle.
Parameters:
Name Type Description
coefficient number Coefficient of force.
area number Area of the plane surface.
angle number Angle of attack of the plane surface.
Source:
Returns:
The force magnitude acting on the plane surface.
Type
number

calculatePolygonArea(vertices) → {number}

Calculates the area of a polygon defined by vertices using the shoelace formula.
Parameters:
Name Type Description
vertices THREE.BufferAttribute | THREE.InterleavedBufferAttribute The vertices of the polygon.
Source:
Returns:
The area of the polygon.
Type
number

drawVectorAsArrow(vector, name, color)

Draws a vector as an arrow in the simulator for visualization.
Parameters:
Name Type Description
vector THREE.Vector3 The vector to be visualized as an arrow.
name string The name identifier for the arrow helper.
color THREE.ColorRepresentation The color of the arrow.
Source:

getAngularFrictionForce() → {THREE.Vector3}

Retrieves the angular friction force acting on the submarine.
Source:
Returns:
The angular friction force acting on the submarine.
Type
THREE.Vector3

getBuoyancy() → {number}

Retrieves the buoyant force acting on the submarine based on its submerged volume and water density.
Source:
Returns:
The buoyant force acting on the submarine.
Type
number

getCrossSectionArea() → {number}

Calculates the cross-sectional area of the submarine perpendicular to its forward direction.
Source:
Returns:
The cross-sectional area of the submarine.
Type
number

getCrossSectionalAreaCSG() → {number}

Retrieves the cross-sectional area of the submarine using CSG operations.
Source:
Returns:
The cross-sectional area of the submarine using CSG operations.
Type
number

getCurrentDepth() → {number}

Retrieves the current depth of the submarine.
Source:
Returns:
The current depth of the submarine.
Type
number

getDrag() → {number}

Retrieves the drag force acting on the submarine based on current velocity and drag coefficients.
Source:
Returns:
The drag force acting on the submarine.
Type
number

getFairwaterPlaneForce() → {THREE.Vector3}

Retrieves the force acting on the fairwater planes of the submarine.
Source:
Returns:
The force acting on the fairwater planes.
Type
THREE.Vector3

getFairwaterTorque() → {THREE.Vector3}

Retrieves the torque produced by the fairwater planes of the submarine.
Source:
Returns:
The torque produced by the fairwater planes.
Type
THREE.Vector3

getFrictionTorque() → {THREE.Vector3}

Retrieves the torque produced by angular friction of the submarine.
Source:
Returns:
The torque produced by angular friction.
Type
THREE.Vector3

getMomentOfInertia() → {THREE.Matrix3}

Retrieves the moment of inertia tensor for the submarine based on its current dimensions and mass.
Source:
Returns:
The moment of inertia tensor.
Type
THREE.Matrix3

getRudderPlaneForce() → {THREE.Vector3}

Retrieves the force acting on the rudder of the submarine.
Source:
Returns:
The force acting on the rudder.
Type
THREE.Vector3

getRudderTorque() → {THREE.Vector3}

Retrieves the torque produced by the rudder of the submarine.
Source:
Returns:
The torque produced by the rudder.
Type
THREE.Vector3

getSternPlaneForce() → {THREE.Vector3}

Retrieves the force acting on the stern planes of the submarine.
Source:
Returns:
The force acting on the stern planes.
Type
THREE.Vector3

getSternTorque() → {THREE.Vector3}

Retrieves the torque produced by the stern planes of the submarine.
Source:
Returns:
The torque produced by the stern planes.
Type
THREE.Vector3

getSubmergedVolume() → {number}

Calculates the submerged volume of the submarine based on its ellipsoid shape and current orientation.
Source:
Returns:
The submerged volume of the submarine.
Type
number

getSubmergedVolumeCSG() → {number}

Retrieves the cross-sectional area of the submarine using CSG operations.
Source:
Returns:
The cross-sectional area of the submarine using CSG operations.
Type
number

getTankWeight() → {number}

Retrieves the weight of water in the submarine's tanks.
Source:
Returns:
The weight of water in the submarine's tanks.
Type
number

getThrust() → {number}

Retrieves the thrust force acting on the submarine based on current rotor speed and coefficients.
Source:
Returns:
The thrust force acting on the submarine.
Type
number

getVolume(geometry) → {number}

Retrieves the volume of a geometry using the signed volume of triangles method.
Parameters:
Name Type Description
geometry THREE.BufferGeometry The geometry whose volume is to be calculated.
Source:
Returns:
The volume of the geometry.
Type
number

getWeight() → {number}

Retrieves the weight acting on the submarine based on its current mass and gravity.
Source:
Returns:
The weight acting on the submarine.
Type
number

getWeightTorque() → {THREE.Vector3}

Retrieves the torque produced by the weight of water in the submarine's tanks.
Source:
Returns:
The torque produced by the weight of water in the tanks.
Type
THREE.Vector3

initCSG_Geometries()

Initializes CSG (Constructive Solid Geometry) geometries for the submarine.
Source:

initCuttingPlaneMesh()

Initializes the cutting plane mesh used in CSG operations.
Source:

initSubmarineEllipsoidMesh()

Initializes the ellipsoid mesh representing the submarine for CSG operations.
Source:

initSurfaceBoxMesh()

Initializes the surface box mesh used in CSG operations.
Source:

signedVolumeOfTriangle(p1, p2, p3) → {number}

Retrieves the volume of an ellipsoid geometry using the formula for an ellipsoid volume.
Parameters:
Name Type Description
p1 number The semi-major axis of the ellipsoid.
p2 number The semi-minor axis of the ellipsoid.
p3 number The semi-minor axis of the ellipsoid.
Source:
Returns:
The volume of the ellipsoid.
Type
number

simulateAngularMotion()

Simulates angular motion of the submarine based on torques (stern, rudder, fairwater, friction, weight).
Source:

simulateLinearMotion()

Simulates linear motion of the submarine based on forces (buoyancy, weight, thrust, drag).
Source:

simulateStep()

Performs one simulation step for the submarine. Updates linear and angular motion based on current forces and torques.
Source:

updateSubmarineEllipsoidMeshPositionAndOrietntation()

Updates the position and orientation of the submarine ellipsoid mesh for CSG operations.
Source: