CustomBallAndSocket::CustomBallAndSocket(const dMatrix& pinAndPivotFrame0, const dMatrix& pinAndPivotFrame1, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) { dMatrix dummy; CalculateLocalMatrix (pinAndPivotFrame0, m_localMatrix0, dummy); CalculateLocalMatrix (pinAndPivotFrame1, dummy, m_localMatrix1); }
////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CustomWormGear::CustomWormGear( dFloat gearRatio, const dVector& rotationalPin, const dVector& linearPin, NewtonBody* rotationalBody, NewtonBody* linearBody) :NewtonCustomJoint(1, rotationalBody, linearBody) { m_gearRatio = gearRatio; // calculate the two local matrix of the pivot point // dVector pivot (0.0f, 0.0f, 0.0f); dMatrix dommyMatrix; // calculate the local matrix for body body0 dMatrix pinAndPivot0 (dgGrammSchmidt (rotationalPin)); // CalculateLocalMatrix (pivot, rotationalPin, m_localMatrix0, dommyMatrix); CalculateLocalMatrix (pinAndPivot0, m_localMatrix0, dommyMatrix); // calculate the local matrix for body body1 // _ASSERTE (0); dMatrix pinAndPivot1 (dgGrammSchmidt(linearPin)); // CalculateLocalMatrix (pivot, linearPin, dommyMatrix, m_localMatrix1); CalculateLocalMatrix (pinAndPivot1, dommyMatrix, m_localMatrix1); }
////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CustomGear::CustomGear( dFloat gearRatio, const dVector& childPin, const dVector& parentPin, NewtonBody* child, NewtonBody* parent) :NewtonCustomJoint(1, child, parent) { m_gearRatio = gearRatio; // calculate the two local matrix of the pivot point // dVector pivot (0.0f, 0.0f, 0.0f); dMatrix dommyMatrix; // calculate the local matrix for body body0 dMatrix pinAndPivot0 (dgGrammSchmidt(childPin)); // CalculateLocalMatrix (pivot, childPin, m_localMatrix0, dommyMatrix); CalculateLocalMatrix (pinAndPivot0, m_localMatrix0, dommyMatrix); // calculate the local matrix for body body1 dMatrix pinAndPivot1 (dgGrammSchmidt(parentPin)); // CalculateLocalMatrix (pivot, parentPin, dommyMatrix, m_localMatrix1); CalculateLocalMatrix (pinAndPivot1, dommyMatrix, m_localMatrix1); }
dCustomBallAndSocket::dCustomBallAndSocket(const dMatrix& pinAndPivotFrame0, const dMatrix& pinAndPivotFrame1, NewtonBody* const child, NewtonBody* const parent) :dCustomJoint(6, child, parent) ,m_twistAngle(0.0f) ,m_minTwistAngle(-180.0f * dDegreeToRad) ,m_maxTwistAngle(180.0f * dDegreeToRad) ,m_maxConeAngle(60.0f * dDegreeToRad) ,m_coneFriction(0.0f) ,m_twistFriction(0.0f) { dMatrix dummy; CalculateLocalMatrix(pinAndPivotFrame0, m_localMatrix0, dummy); CalculateLocalMatrix(pinAndPivotFrame1, dummy, m_localMatrix1); }
CustomHinge::CustomHinge (const dMatrix& pinAndPivotFrameChild, const dMatrix& pinAndPivotFrameParent, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) ,m_curJointAngle() ,m_minAngle(-45.0f * 3.141592f / 180.0f) ,m_maxAngle(45.0f * 3.141592f / 180.0f) ,m_friction(0.0f) ,m_jointOmega(0.0f) ,m_limitsOn(false) ,m_lastRowWasUsed(false) { dMatrix dummy; CalculateLocalMatrix (pinAndPivotFrameChild, m_localMatrix0, dummy); CalculateLocalMatrix (pinAndPivotFrameParent, dummy, m_localMatrix1); }
CustomMultiBodyVehicle::CustomMultiBodyVehicle(const dVector& frontDir, const dVector& upDir, const NewtonBody* carBody) :NewtonCustomJoint(1, carBody, NULL) { dVector com; dMatrix tmp; dMatrix chassisMatrix; m_tiresCount = 0; m_diffencialCount = 0; NewtonBodyGetMatrix(m_body0, &tmp[0][0]); NewtonBodyGetCentreOfMass(m_body0, &com[0]); com.m_w = 1.0f; // set the joint reference point at the center of mass of the body chassisMatrix.m_front = frontDir; chassisMatrix.m_up = upDir; chassisMatrix.m_right = frontDir * upDir; chassisMatrix.m_posit = tmp.TransformVector(com); chassisMatrix.m_front.m_w = 0.0f; chassisMatrix.m_up.m_w = 0.0f; chassisMatrix.m_right.m_w = 0.0f; chassisMatrix.m_posit.m_w = 1.0f; CalculateLocalMatrix (chassisMatrix, m_localFrame, tmp); }
void BeamElement::CalculateLocalNodalStress(Vector& Stress) { Matrix Rotation; Matrix LocalMatrix; array_1d<double, 12 > CurrentDisplacement; array_1d<double, 12 > LocalDisplacement; Vector LocalBody = ZeroVector(12); Vector GlobalBody = ZeroVector(12); Rotation.resize(12,12, false); Stress.resize(12, false); CurrentDisplacement(0) = GetGeometry()[0].GetSolutionStepValue(DISPLACEMENT_X); CurrentDisplacement(1) = GetGeometry()[0].GetSolutionStepValue(DISPLACEMENT_Y); CurrentDisplacement(2) = GetGeometry()[0].GetSolutionStepValue(DISPLACEMENT_Z); CurrentDisplacement(3) = GetGeometry()[0].GetSolutionStepValue(ROTATION_X); CurrentDisplacement(4) = GetGeometry()[0].GetSolutionStepValue(ROTATION_Y); CurrentDisplacement(5) = GetGeometry()[0].GetSolutionStepValue(ROTATION_Z); CurrentDisplacement(6) = GetGeometry()[1].GetSolutionStepValue(DISPLACEMENT_X); CurrentDisplacement(7) = GetGeometry()[1].GetSolutionStepValue(DISPLACEMENT_Y); CurrentDisplacement(8) = GetGeometry()[1].GetSolutionStepValue(DISPLACEMENT_Z); CurrentDisplacement(9) = GetGeometry()[1].GetSolutionStepValue(ROTATION_X); CurrentDisplacement(10) = GetGeometry()[1].GetSolutionStepValue(ROTATION_Y); CurrentDisplacement(11) = GetGeometry()[1].GetSolutionStepValue(ROTATION_Z); CalculateTransformationMatrix(Rotation); CalculateLocalMatrix(LocalMatrix); noalias(LocalDisplacement) = prod(Matrix(trans(Rotation)), CurrentDisplacement); CalculateBodyForce(Rotation, LocalBody, GlobalBody); noalias(Stress) = -LocalBody + prod(LocalMatrix, LocalDisplacement); // noalias(Stress) = -LocalBody + prod(Matrix(prod(Rotation,LocalMatrix)), LocalDisplacement); return; }
int DP_MultipleLocalBlockAlign( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_MultipleAlignmentResults **alignments, unsigned int maxAlignments) { if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_MultipleLocalBlockAlign() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } for (unsigned int block=0; block<blocks->nBlocks; ++block) { if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK) { WARNING_MESSAGE("DP_MultipleLocalBlockAlign() - frozen block specifications are ignored..."); break; } } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); int status = CalculateLocalMatrix(matrix, blocks, BlockScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_MultipleLocalBlockAlign() - CalculateLocalMatrix() failed"); return status; } return TracebackMultipleLocalAlignments(matrix, blocks, queryFrom, queryTo, alignments, maxAlignments); }
CustomRackAndPinion::CustomRackAndPinion(dFloat gearRatio, const dVector& rotationalPin, const dVector& linearPin, NewtonBody* rotationalBody, NewtonBody* linearBody) :CustomJoint(1, rotationalBody, linearBody) { m_gearRatio = gearRatio; dMatrix dommyMatrix; dMatrix pinAndPivot0 (dGrammSchmidt (rotationalPin)); CalculateLocalMatrix (pinAndPivot0, m_localMatrix0, dommyMatrix); m_localMatrix0.m_posit = dVector (0.0f, 0.0f, 0.0f, 1.0f); // calculate the local matrix for body body1 dMatrix pinAndPivot1 (dGrammSchmidt(linearPin)); CalculateLocalMatrix (pinAndPivot1, dommyMatrix, m_localMatrix1); m_localMatrix1.m_posit = dVector (0.0f, 0.0f, 0.0f, 1.0f); }
////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CustomPulley::CustomPulley(dFloat gearRatio, const dVector& childPin, const dVector& parentPin, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(1, child, parent) { m_gearRatio = gearRatio; // calculate the two local matrix of the pivot point dMatrix dommyMatrix; // calculate the local matrix for body body0 dMatrix pinAndPivot0 (dGrammSchmidt (childPin)); CalculateLocalMatrix (pinAndPivot0, m_localMatrix0, dommyMatrix); m_localMatrix0.m_posit = dVector (0.0f, 0.0f, 0.0f, 1.0f); // calculate the local matrix for body body1 dMatrix pinAndPivot1 (dGrammSchmidt (parentPin)); CalculateLocalMatrix (pinAndPivot1, dommyMatrix, m_localMatrix1); m_localMatrix1.m_posit = dVector (0.0f, 0.0f, 0.0f, 1.0f); }
CustomPathFollow::CustomPathFollow (const dMatrix& pinAndPivotFrame, NewtonBody* const child) :CustomJoint(6, child, NULL) ,m_pathTangent (1.0f, 0.0f, 0.0f, 0.0f) ,m_pointOnPath (0.0f, 10.0f, 0.0f, 0.0) { // calculate the two local matrix of the pivot point dMatrix tmp; CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, tmp); }
CustomPointToPoint::CustomPointToPoint(const dVector& pivotInChildInGlobalSpace, const dVector& pivotInParentInGlobalSpace, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) { dVector dist(pivotInChildInGlobalSpace - pivotInParentInGlobalSpace); m_distance = dSqrt(dist % dist); dMatrix childMatrix(dGetIdentityMatrix()); dMatrix parentMatrix(dGetIdentityMatrix()); childMatrix.m_posit = pivotInChildInGlobalSpace; parentMatrix.m_posit = pivotInParentInGlobalSpace; childMatrix.m_posit.m_w = 1.0f; parentMatrix.m_posit.m_w = 1.0f; dMatrix dummy; CalculateLocalMatrix(childMatrix, m_localMatrix0, dummy); CalculateLocalMatrix(parentMatrix, dummy, m_localMatrix1); }
CustomLimitBallAndSocket::CustomLimitBallAndSocket(const dMatrix& childPinAndPivotFrame, NewtonBody* const child, const dMatrix& parentPinAndPivotFrame, NewtonBody* const parent) :CustomBallAndSocket(childPinAndPivotFrame, child, parent) ,m_rotationOffset(childPinAndPivotFrame * parentPinAndPivotFrame.Inverse()) { SetConeAngle (0.0f); SetTwistAngle (0.0f, 0.0f); dMatrix matrix; CalculateLocalMatrix (parentPinAndPivotFrame, matrix, m_localMatrix1); }
CustomHinge::CustomHinge(const dVector& pivot, const dVector& pin, NewtonBody* child, NewtonBody* parent) :NewtonCustomJoint(6, child, parent) { m_limitsOn = false; m_minAngle = -45.0f * 3.1416f / 180.0f; m_maxAngle = 45.0f * 3.1416f / 180.0f; // calculate the two local matrix of the pivot point CalculateLocalMatrix (pivot, pin, m_localMatrix0, m_localMatrix1); }
CustomSlider::CustomSlider (const dMatrix& pinAndPivotFrame, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) ,m_speed(0.0f) ,m_posit(0.0f) ,m_minDist(-1.0f) ,m_maxDist(1.0f) ,m_limitsOn(false) { // calculate the two local matrix of the pivot point CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, m_localMatrix1); }
dCustomUpVector::dCustomUpVector(const dVector& pin, NewtonBody* child) :dCustomJoint(2, child, NULL) { dMatrix pivot; NewtonBodyGetMatrix(child, &pivot[0][0]); dMatrix matrix (dGrammSchmidt(pin)); matrix.m_posit = pivot.m_posit; CalculateLocalMatrix (matrix, m_localMatrix0, m_localMatrix1); }
Custom6DOF::Custom6DOF (const dMatrix& pinsAndPivotChildFrame, const dMatrix& pinsAndPivotParentFrame___, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) ,m_minLinearLimits(0.0f, 0.0f, 0.0f, 0.0f) ,m_maxLinearLimits(0.0f, 0.0f, 0.0f, 0.0f) ,m_minAngularLimits(0.0f, 0.0f, 0.0f, 0.0f) ,m_maxAngularLimits(0.0f, 0.0f, 0.0f, 0.0f) ,m_pitch() ,m_yaw() ,m_roll() { CalculateLocalMatrix (pinsAndPivotChildFrame, m_localMatrix0, m_localMatrix1); }
CustomHinge::CustomHinge (const dMatrix& pinAndPivotFrame, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) ,m_curJointAngle() ,m_minAngle(-45.0f * 3.141592f / 180.0f) ,m_maxAngle(45.0f * 3.141592f / 180.0f) ,m_friction(0.0f) ,m_jointOmega(0.0f) ,m_limitsOn(false) ,m_lastRowWasUsed(false) { // calculate the two local matrix of the pivot point CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, m_localMatrix1); }
CustomCorkScrew::CustomCorkScrew(const dVector& pivot, const dVector& pin, NewtonBody* child, NewtonBody* parent) :NewtonCustomJoint(6, child, parent) { m_limitsOn = false; m_minDist = -1.0f; m_maxDist = 1.0f; m_angularmotorOn = true; m_angularDamp = 0.1f; m_angularAccel = 5.0f; // calculate the two local matrix of the pivot point CalculateLocalMatrix (pivot, pin, m_localMatrix0, m_localMatrix1); }
CustomSlider::CustomSlider (const dMatrix& pinAndPivotFrame, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) { m_limitsOn = false; m_hitLimitOnLastUpdate = false; m_speed = 0.0f; m_posit = 0.0f; m_minDist = -1.0f; m_maxDist = 1.0f; // calculate the two local matrix of the pivot point CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, m_localMatrix1); }
CustomHinge::CustomHinge (const dMatrix& pinAndPivotFrame, const NewtonBody* child, const NewtonBody* parent) :NewtonCustomJoint(6, child, parent), m_curJointAngle() { m_limitsOn = false; m_jointOmega = 0.0f; m_minAngle = -45.0f * 3.141592f / 180.0f; m_maxAngle = 45.0f * 3.141592f / 180.0f; // // the joint current angle is zero at joint creation time // m_curJointAngle = 0.0f; // calculate the two local matrix of the pivot point CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, m_localMatrix1); }
CustomSlidingContact::CustomSlidingContact (const dMatrix& pinAndPivotFrame, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) ,m_curJointAngle() ,m_speed(0.0f) ,m_posit(0.0f) { EnableLinearLimits(false); EnableAngularLimits(false); SetLinearLimis(-1.0f, 1.0f); SetAngularLimis(-30.0f * 3.141592f / 180.0f, 30.0f * 3.141592f / 180.0f); // calculate the two local matrix of the pivot point CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, m_localMatrix1); }
dCustomTireSpringDG::dCustomTireSpringDG(const dMatrix& pinAndPivotFrameChild, const dMatrix& pinAndPivotFrameParent, NewtonBody* const child, NewtonBody* const parent) :dCustomJoint(6, child, parent), mUseBreak(false), mUseSteer(false), mUseTorque(false), mUseHardBreak(false), mIxx(0.0f), mIyy(0.0f), mIzz(0.0f), mRealOmega(0.0f), mTireOmegaCorrection(0.975f), mFpsRequest(120.0f), mTireTorque(0.0f), mBrakeTorque(0.0f), mSteerAngle(0.0f), mAttachmentLength(10.0f), mDistance(0.0f), mMinSuspenssion(-0.25f), mMaxSuspenssion(0.0f), mSpringK(150.0f), mSpringD(5.0f), mSpringMassEffective(0.5f), mAccel(0.0f), mAttachMass(0.0f), mCenterInTire(dVector(0.0f, 0.0f, 0.0f)), mCenterInChassis(dVector(0.0f, 0.0f, 0.0f)), mChassisPivotMatrix(dGetIdentityMatrix()), mTirePivotMatrix(dGetIdentityMatrix()), mRefFrameLocalMatrix(dGetIdentityMatrix()) { dMatrix dummy; CalculateLocalMatrix(pinAndPivotFrameChild, m_localMatrix0, dummy); CalculateLocalMatrix(pinAndPivotFrameParent, dummy, m_localMatrix1); // mRefFrameLocalMatrix = m_localMatrix0; NewtonBodyGetMass(parent, &mAttachMass, &mIxx, &mIyy, &mIzz); }
void dCustomKinematicController::Init (NewtonBody* const body, const dMatrix& matrix) { CalculateLocalMatrix(matrix, m_localMatrix0, m_localMatrix1); m_autoSleepState = NewtonBodyGetAutoSleep(body) ? true : false; NewtonBodySetSleepState(body, 0); SetPickMode(1); SetLimitRotationVelocity(10.0f); SetTargetMatrix(matrix); SetMaxLinearFriction(1.0f); SetMaxAngularFriction(1.0f); // set as soft joint SetSolverModel(2); }
dAnimationRigHinge::dAnimationRigHinge(const dMatrix& basicMatrix, dAnimationRigJoint* const parent, NewtonBody* const body) :dAnimationRigLimb(parent, body) ,dCustomHinge (basicMatrix, body, parent->GetNewtonBody()) ,m_rowAccel(0.0f) { dMatrix boneAligmentMatrix( dVector( 0.0f, 1.0f, 0.0f, 0.0f), dVector( 0.0f, 0.0f, 1.0f, 0.0f), dVector( 1.0f, 0.0f, 0.0f, 0.0f), dVector( 0.0f, 0.0f, 0.0f, 1.0f)); dMatrix matrix (boneAligmentMatrix * basicMatrix); CalculateLocalMatrix(matrix, m_localMatrix0, m_localMatrix1); EnableLimits(true); }
CustomConeLimitedBallAndSocket::CustomConeLimitedBallAndSocket( dFloat twistAngle, dFloat coneAngle, const dVector& coneDir, const dVector& pivot, NewtonBody* child, NewtonBody* parent) :CustomBallAndSocket(pivot, child, parent) { m_coneAngle = coneAngle; m_coneAngle = twistAngle; m_cosConeAngle = dCos (m_coneAngle); // Recalculate local matrices so that the front vector align with the cone pin CalculateLocalMatrix (pivot, coneDir, m_localMatrix0, m_localMatrix1); }
CustomCorkScrew::CustomCorkScrew (const dMatrix& pinAndPivotFrame, NewtonBody* child, NewtonBody* parent) :CustomJoint(6, child, parent) ,m_curJointAngle() { m_limitsLinearOn = false; m_limitsAngularOn = false; m_minLinearDist = -1.0f; m_maxLinearDist = 1.0f; m_minAngularDist = -1.0f; m_maxAngularDist = 1.0f; m_angularmotorOn = false; m_angularDamp = 0.1f; m_angularAccel = 5.0f; // calculate the two local matrix of the pivot point CalculateLocalMatrix (pinAndPivotFrame, m_localMatrix0, m_localMatrix1); }
void BeamElement::CalculateLHS(Matrix& rLeftHandSideMatrix) { Matrix LocalMatrix; Matrix Rotation; Matrix aux_matrix; LocalMatrix.resize(12,12, false); Rotation.resize(12,12, false); aux_matrix.resize(12,12, false); rLeftHandSideMatrix.resize(12,12,false); CalculateLocalMatrix(LocalMatrix); CalculateTransformationMatrix(Rotation); noalias(aux_matrix) = prod(Rotation, LocalMatrix); noalias(rLeftHandSideMatrix)= prod(aux_matrix,Matrix(trans(Rotation))); return; }
CustomMultiBodyVehicleTire( const NewtonBody* hubBody, const NewtonBody* tire, dFloat suspensionLength, dFloat springConst, dFloat damperConst, dFloat radio) :NewtonCustomJoint(6, hubBody, tire) { dFloat mass; dFloat Ixx; dFloat Iyy; dFloat Izz; dMatrix pinAndPivotFrame; m_radius = radio; m_steeAngle = 0.0f; m_brakeToque = 0.0f; m_enginetorque = 0.0f; m_angularDragCoef = 0.0f; m_spring = springConst; m_damper = damperConst; m_suspenstionSpan = suspensionLength; NewtonBodyGetMassMatrix(tire, &mass, &Ixx, &Iyy, &Izz); m_Ixx = Ixx; // dFloat mass0; // dFloat mass1; // NewtonBodyGetMassMatrix(hubBody, &mass1, &Ixx, &Iyy, &Izz); // m_effectiveSpringMass = mass0 * mass1 / (mass0 + mass1); NewtonBodyGetMassMatrix(hubBody, &mass, &Ixx, &Iyy, &Izz); m_effectiveSpringMass = mass * 0.25f; NewtonBodyGetMatrix(tire, &pinAndPivotFrame[0][0]); CalculateLocalMatrix (pinAndPivotFrame, m_chassisLocalMatrix, m_tireLocalMatrix); m_refChassisLocalMatrix = m_chassisLocalMatrix; }
CustomUniversal::CustomUniversal(const dMatrix& pinAndPivotFrame, NewtonBody* const child, NewtonBody* const parent) :CustomJoint(6, child, parent) ,m_curJointAngle_0() ,m_curJointAngle_1() { // calculate the relative matrix of the pin and pivot on each body CalculateLocalMatrix(pinAndPivotFrame, m_localMatrix0, m_localMatrix1); m_limit_0_On = true; m_angularMotor_0_On = false; m_angularDamp_0 = 0.5f; m_angularAccel_0 = -4.0f; m_jointOmega_0 = 0.0f; m_minAngle_0 = -45.0f * 3.141592f / 180.0f; m_maxAngle_0 = 45.0f * 3.141592f / 180.0f; m_limit_1_On = true; m_angularMotor_1_On = false; m_angularDamp_1 = 0.3f; m_angularAccel_1 = -4.0f; m_jointOmega_1 = 0.0f; m_minAngle_1 = -45.0f * 3.141592f / 180.0f; m_maxAngle_1 = 45.0f * 3.141592f / 180.0f; }