Some tweaks with the mechanical and electric grid

This commit is contained in:
Calclavia 2015-01-23 14:54:19 +08:00
parent 8ad5a353c1
commit e9afa8c070
4 changed files with 17 additions and 18 deletions

View File

@ -61,7 +61,7 @@ class TileMotor extends SpatialTile(Material.iron) with TIO with TElectric with
nodes.add(electricNode)
nodes.add(mechNode)
electricNode.resistance = 10
electricNode.resistance = 1
def toggleGearRatio() = (gearRatio + 1) % 3
@ -87,6 +87,13 @@ class TileMotor extends SpatialTile(Material.iron) with TIO with TElectric with
{
super.update()
/**
* Produce torque based on current.
* T = NBA * I / (2pi)
*/
val torque = TileMotor.motorConstant * electricNode.current / (2 * Math.PI)
mechNode.accelerate(torque)
/**
* Motors produce emf or counter-emf by Lenz's law based on angular velocity
* emf = change of flux/time
@ -97,14 +104,7 @@ class TileMotor extends SpatialTile(Material.iron) with TIO with TElectric with
* where w = angular velocity
*/
val inducedEmf = TileMotor.motorConstant * mechNode.angularVelocity // * Math.sin(mechNode.angularVelocity * System.currentTimeMillis() / 1000d)
/**
* Produce torque based on current.
* T = NBA * I / (2pi)
*/
val torque = TileMotor.motorConstant * electricNode.current / (2 * Math.PI)
mechNode.accelerate(torque)
electricNode.generateVoltage(inducedEmf)
electricNode.generateVoltage(inducedEmf * -1)
}
override def setIO(dir: ForgeDirection, ioType: Int)

View File

@ -24,9 +24,9 @@ class NodeGear(parent: PartGear) extends NodeMechanical(parent: PartGear)
{
gear.tier match
{
case 0 => 50
case 1 => 80
case 2 => 75
case 0 => 8
case 1 => 20
case 2 => 15
}
}

View File

@ -14,9 +14,9 @@ class NodeGearShaft(parent: PartGearShaft) extends NodeMechanical(parent)
{
return shaft.tier match
{
case 0 => 15
case 1 => 10
case 2 => 5
case 0 => 3
case 1 => 5
case 2 => 4
}
}

View File

@ -158,15 +158,14 @@ class GridMechanical extends GridNode[NodeMechanical] with IUpdate
* where I = inertia and a = angular acceleration
*/
val inertia = calculateEquivalentInertia(passed)
val netTorque = torque
val netAcceleration = torque / inertia
curr.torque += netTorque
curr.torque += torque
curr.angularVelocity += netAcceleration * deltaTime
curr.connections.foreach(c =>
{
allDistributed :+= c
recurse(passed :+ c, deltaTime, netTorque, netAcceleration)
recurse(passed :+ c, deltaTime, torque, netAcceleration)
})
}
}