Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JunePrimavera committed Sep 4, 2023
1 parent 8576cfa commit 2860885
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
24 changes: 16 additions & 8 deletions src/main/java/io/github/teampropulsive/physics/Aero.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ import io.github.teampropulsive.types.AtmoCompositionGas
import net.minecraft.util.math.Vec3d

class Aero {
fun calculate_aero(velocity : Vec3d, drag_coefficient : Double, area_in_direction : Double, atmo : ArrayList<AtmoCompositionGas>): Vec3d {
var average_density = 0.0;
for (gas in atmo) {
average_density += gas.gas.density * gas.quantity
}
average_density /= atmo.size.toDouble()
val force = velocity.multiply(velocity).multiply(average_density).multiply(0.5).multiply(drag_coefficient).multiply(area_in_direction)
return force
fun calculate_aero(
velocity: Vec3d,
dragCoefficient: Double,
areaInDirection: Double,
atmo: ArrayList<AtmoCompositionGas>
): Vec3d {
var averageDensity = 0.0;
for (gas in atmo)
averageDensity += gas.gas.density * gas.quantity
averageDensity /= atmo.size.toDouble()
return velocity
.multiply(velocity)
.multiply(averageDensity)
.multiply(0.5)
.multiply(dragCoefficient)
.multiply(areaInDirection)
}
}
8 changes: 5 additions & 3 deletions src/main/java/io/github/teampropulsive/physics/Gravity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ class Gravity {
fun calculate(position : Vec3d): Vec3d? {
val planet = get_parent_planet(position)
if (planet != null) {
var force = Vec3d(planet.currentPos.x - position.x, planet.currentPos.y - position.y, planet.currentPos.z - position.z)
var force = Vec3d(
planet.currentPos.x - position.x,
planet.currentPos.y - position.y,
planet.currentPos.z - position.z
)
val d = planet.currentPos.squaredDistanceTo(position)
val m = ((planet.planetSize + 1.0) * (planet.planetSize + 1.0) * (planet.planetSize + 1.0) * (planet.planetSize + 1.0))
val g = 6.1

force = force.normalize()
force = force.multiply(m * g)

return Vec3d(
force.x / d,
force.y / d,
Expand Down

0 comments on commit 2860885

Please sign in to comment.