public UnitCircularWireConstraint(Particle a_Particle, ParticleSystem a_System) { int i = a_System.AddConstraint(this); Debug.Log("Creating unit circular wire constraint with index " + i); m_Particle = a_Particle; int j = a_System.GetParticleIndex(a_Particle) * a_System.GetParticleDimension(); int iLength = GetConstraintDimension(); int jLength = a_System.GetParticleDimension(); m_MatrixBlockJ = a_System.MatrixJ.CreateMatrixBlock(i, j, iLength, jLength); m_MatrixBlockJDot = a_System.MatrixJDot.CreateMatrixBlock(i, j, iLength, jLength); }
public FixedPointConstraint(Particle a_Particle, ParticleSystem a_System) { m_Particle = a_Particle; m_Center = new Vector2(a_Particle.Position.x, a_Particle.Position.y); // We can probably de-duplicate this code: int j = a_System.GetParticleIndex(a_Particle) * a_System.GetParticleDimension(); int i = a_System.AddConstraint(this); Debug.Log("Creating fixed point V constraint with index " + i); int iLength = GetConstraintDimension(); int jLength = a_System.GetParticleDimension(); m_MatrixBlockJ = a_System.MatrixJ.CreateMatrixBlock(i, j, iLength, jLength); m_MatrixBlockJDot = a_System.MatrixJDot.CreateMatrixBlock(i, j, iLength, jLength); }
public VLineConstraint(Particle a_Particle, ParticleSystem a_System) { m_Particle = a_Particle; m_X = a_Particle.Position.x; // We can probably de-duplicate this code: int j = a_System.GetParticleIndex(a_Particle) * a_System.GetParticleDimension(); int i = a_System.AddConstraint(this); Debug.Log("Creating VLine constraint with index " + i); int iLength = GetConstraintDimension(); int jLength = a_System.GetParticleDimension(); m_MatrixBlockJ = a_System.MatrixJ.CreateMatrixBlock(i, j, iLength, jLength); m_MatrixBlockJDot = a_System.MatrixJDot.CreateMatrixBlock(i, j, iLength, jLength); }
public CircularWireConstraint(Particle a_Particle, Vector2 a_Center, ParticleSystem a_System) { int i = a_System.AddConstraint(this); Debug.Log("Creating " + (OLD ? "old" : "new") + " circular wire constraint with index " + i); m_Particle = a_Particle; m_Center = a_Center; m_Radius = (a_Particle.Position - a_Center).magnitude; m_RadiusSquared = m_Radius * m_Radius; int j = a_System.GetParticleIndex(a_Particle) * a_System.GetParticleDimension(); int iLength = GetConstraintDimension(); int jLength = a_System.GetParticleDimension(); m_MatrixBlockJ = a_System.MatrixJ.CreateMatrixBlock(i, j, iLength, jLength); m_MatrixBlockJDot = a_System.MatrixJDot.CreateMatrixBlock(i, j, iLength, jLength); }
public AnyLineConstraint(Particle a_Particle, Vector2 a_A, ParticleSystem a_System) { m_Particle = a_Particle; m_A = a_A.normalized; m_B = a_Particle.Position; m_Aperp = new Vector2(a_A.y, -a_A.x); // We can probably de-duplicate this code: int j = a_System.GetParticleIndex(a_Particle) * a_System.GetParticleDimension(); int i = a_System.AddConstraint(this); Debug.Log("Creating fixed point V constraint with index " + i); int iLength = GetConstraintDimension(); int jLength = a_System.GetParticleDimension(); m_MatrixBlockJ = a_System.MatrixJ.CreateMatrixBlock(i, j, iLength, jLength); m_MatrixBlockJDot = a_System.MatrixJDot.CreateMatrixBlock(i, j, iLength, jLength); }
public RodConstraint(Particle a_ParticleA, Particle a_ParticleB, ParticleSystem a_System) { int i = a_System.AddConstraint(this); Debug.Log("Creating " + (OLD ? "old" : "new") + " rod constraint with index " + i); m_Distance = (a_ParticleA.Position - a_ParticleB.Position).magnitude; m_DistanceSquared = m_Distance * m_Distance; m_ParticleA = a_ParticleA; m_ParticleB = a_ParticleB; int iLength = GetConstraintDimension(); int jLength = a_System.GetParticleDimension(); // We can probably de-duplicate this code: int j_A = a_System.GetParticleIndex(a_ParticleA) * a_System.GetParticleDimension(); int j_B = a_System.GetParticleIndex(a_ParticleB) * a_System.GetParticleDimension(); m_MatrixBlockJ_A = a_System.MatrixJ.CreateMatrixBlock(i, j_A, iLength, jLength); m_MatrixBlockJ_B = a_System.MatrixJ.CreateMatrixBlock(i, j_B, iLength, jLength); m_MatrixBlockJDot_A = a_System.MatrixJDot.CreateMatrixBlock(i, j_A, iLength, jLength); m_MatrixBlockJDot_B = a_System.MatrixJDot.CreateMatrixBlock(i, j_B, iLength, jLength); }
public EllipticalWireConstraint(Particle a_Particle, Vector2 a_Center1, Vector2 a_Center2, ParticleSystem a_System) { int i = a_System.AddConstraint(this); Debug.Log("Creating elliptical wire constraint with index " + i); m_Particle = a_Particle; m_Focus1 = a_Center1; m_Focus2 = a_Center2; m_Midpoint = 0.5f * (a_Center1 + a_Center2); m_Radius = (a_Particle.Position - a_Center1).magnitude + (a_Particle.Position - a_Center2).magnitude; m_C = (a_Center1 - a_Center2).magnitude / 2; m_A = m_Radius / 2; m_B = Mathf.Sqrt(m_A * m_A - m_C * m_C); //Debug.Log("a = " + m_A + ", b = " + m_B); m_Tilt = Mathf.Acos(Vector2.Dot(Vector2.right, (m_Focus1 - m_Focus2).normalized)); int j = a_System.GetParticleIndex(a_Particle) * a_System.GetParticleDimension(); int iLength = GetConstraintDimension(); int jLength = a_System.GetParticleDimension(); m_MatrixBlockJ = a_System.MatrixJ.CreateMatrixBlock(i, j, iLength, jLength); m_MatrixBlockJDot = a_System.MatrixJDot.CreateMatrixBlock(i, j, iLength, jLength); }