コード例 #1
0
        /// Override _all_ time, jacobian etc. updating.
        /// In detail, it computes jacobians, violations, etc. and stores
        /// results in inner structures.
        public override void update(double mytime, bool update_assets = true)
        {
            // Inherit time changes of parent class (ChLink), basically doing nothing :)
            base.update(mytime, update_assets);

            // compute jacobians
            ChVector AbsDist = Body1.TransformPointLocalToParent(pos1) - Body2.TransformPointLocalToParent(pos2);

            curr_dist = AbsDist.Length();
            ChVector D2abs  = ChVector.Vnorm(AbsDist);
            ChVector D2relB = Body2.TransformDirectionParentToLocal(D2abs);
            ChVector D2relA = Body1.TransformDirectionParentToLocal(D2abs);

            ChVector CqAx = D2abs;
            ChVector CqBx = -D2abs;

            ChVector CqAr = -ChVector.Vcross(D2relA, pos1);
            ChVector CqBr = ChVector.Vcross(D2relB, pos2);

            Cx.Get_Cq_a().ElementN(0) = CqAx.x;
            Cx.Get_Cq_a().ElementN(1) = CqAx.y;
            Cx.Get_Cq_a().ElementN(2) = CqAx.z;
            Cx.Get_Cq_a().ElementN(3) = CqAr.x;
            Cx.Get_Cq_a().ElementN(4) = CqAr.y;
            Cx.Get_Cq_a().ElementN(5) = CqAr.z;

            Cx.Get_Cq_b().ElementN(0) = CqBx.x;
            Cx.Get_Cq_b().ElementN(1) = CqBx.y;
            Cx.Get_Cq_b().ElementN(2) = CqBx.z;
            Cx.Get_Cq_b().ElementN(3) = CqBr.x;
            Cx.Get_Cq_b().ElementN(4) = CqBr.y;
            Cx.Get_Cq_b().ElementN(5) = CqBr.z;

            //***TO DO***  C_dt? C_dtdt? (may be never used..)
        }
コード例 #2
0
        /// Specialized initialization for generic mate, given the two bodies to be connected, the
        /// positions of the two frames to connect on the bodies (each expressed
        /// in body or abs. coordinates).
        public virtual void Initialize(ChBodyFrame mbody1,     //< first body to link
                                       ChBodyFrame mbody2,     /// second body to link
                                       bool pos_are_relative,  //< true: following pos. are relative to bodies.
                                       ChFrame <double> mpos1, //< mate frame (slave), for 1st body (rel. or abs., see flag above)
                                       ChFrame <double> mpos2  //< mate frame (master), for 2nd body (rel. or abs., see flag above)
                                       )
        {
            Debug.Assert(mbody1 != mbody2);

            this.Body1 = mbody1;
            this.Body2 = mbody2;
            // this.SetSystem(mbody1.GetSystem());

            this.mask.SetTwoBodiesVariables(Body1.Variables(), Body2.Variables());

            if (pos_are_relative)
            {
                this.frame1 = mpos1;
                this.frame2 = mpos2;
            }
            else
            {
                // from abs to body-rel
                (this.Body1).TransformParentToLocal(mpos1, this.frame1);
                this.Body2.TransformParentToLocal(mpos2, this.frame2);
            }
        }
コード例 #3
0
        public static void Run(IReadOnlyDictionary <string, string> configDictionary)
        {
            var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1";
            var tokenId   = "7020000000000137654";

            var requestObj = new Body1();

            var processingInformationObj = new InstrumentidentifiersProcessingInformation();

            var authorizationOptionsObj = new InstrumentidentifiersProcessingInformationAuthorizationOptions();

            var initiatorObj = new InstrumentidentifiersProcessingInformationAuthorizationOptionsInitiator();

            var merchantInitiatedTransactionObj = new InstrumentidentifiersProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction();

            merchantInitiatedTransactionObj.PreviousTransactionId = "123456789012345";
            initiatorObj.MerchantInitiatedTransaction             = merchantInitiatedTransactionObj;

            authorizationOptionsObj.Initiator = initiatorObj;

            processingInformationObj.AuthorizationOptions = authorizationOptionsObj;

            requestObj.ProcessingInformation = processingInformationObj;

            try
            {
                var apiInstance = new InstrumentIdentifierApi();
                var result      = apiInstance.InstrumentidentifiersTokenIdPatch(profileId, tokenId, requestObj);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
コード例 #4
0
        /// Initialization based on passing two vectors (point + dir) on the
        /// two bodies, they will represent the X axes of the two frames (Y and Z will
        /// be built from the X vector via Gram Schmidt orthonormalization).
        /// Use the other ChLinkMateGeneric::Initialize() if you want to set the two frames directly.
        public virtual void Initialize(ChBodyFrame mbody1,    //< first body to link
                                       ChBodyFrame mbody2,    //< second body to link
                                       bool pos_are_relative, //< true: following pos. are relative to bodies.
                                       ChVector mpt1,         //< origin of slave frame 1, for 1st body (rel. or abs., see flag above)
                                       ChVector mpt2,         //< origin of master frame 2, for 2nd body (rel. or abs., see flag above)
                                       ChVector mnorm1,       //< X axis of slave plane, for 1st body (rel. or abs., see flag above)
                                       ChVector mnorm2        //< X axis of master plane, for 2nd body (rel. or abs., see flag above)
                                       )
        {
            Debug.Assert(mbody1 != mbody2);

            this.Body1 = mbody1;
            this.Body2 = mbody2;
            // this.SetSystem(mbody1.GetSystem());

            this.mask.SetTwoBodiesVariables(Body1.Variables(), Body2.Variables());

            ChVector            mx   = new ChVector(0, 0, 0);
            ChVector            my   = new ChVector(0, 0, 0);
            ChVector            mz   = new ChVector(0, 0, 0);
            ChVector            mN   = new ChVector(0, 0, 0);
            ChMatrix33 <double> mrot = new ChMatrix33 <double>();

            ChFrame <double> mfr1 = new ChFrame <double>();
            ChFrame <double> mfr2 = new ChFrame <double>();

            if (pos_are_relative)
            {
                mN = mnorm1;
                mN.DirToDxDyDz(ref mx, ref my, ref mz, new ChVector(0, 1, 0));
                mrot.Set_A_axis(mx, my, mz);
                mfr1.SetRot(mrot);
                mfr1.SetPos(mpt1);

                mN = mnorm2;
                mN.DirToDxDyDz(ref mx, ref my, ref mz, new ChVector(0, 1, 0));
                mrot.Set_A_axis(mx, my, mz);
                mfr2.SetRot(mrot);
                mfr2.SetPos(mpt2);
            }
            else
            {
                ChVector temp = ChVector.VECT_Z;
                // from abs to body-rel
                mN = this.Body1.TransformDirectionParentToLocal(mnorm1);
                mN.DirToDxDyDz(ref mx, ref my, ref mz, temp);
                mrot.Set_A_axis(mx, my, mz);
                mfr1.SetRot(mrot);
                mfr1.SetPos(this.Body1.TransformPointParentToLocal(mpt1));

                mN = this.Body2.TransformDirectionParentToLocal(mnorm2);
                mN.DirToDxDyDz(ref mx, ref my, ref mz, temp);
                mrot.Set_A_axis(mx, my, mz);
                mfr2.SetRot(mrot);
                mfr2.SetPos(this.Body2.TransformPointParentToLocal(mpt2));
            }

            this.frame1 = mfr1;
            this.frame2 = mfr2;
        }
コード例 #5
0
            public override void Iterate()
            {
                _deltaVelocity   = TargetVelocity - Body1.LinearVelocity;
                _deltaVelocity.Y = 0.0f;

                _deltaVelocity *= Stiffness;

                if (Math.Abs(_deltaVelocity.LengthSquared()) > 0.00001f)
                {
                    Body1.IsActive = true;
                    Body1.ApplyImpulse(_deltaVelocity * Body1.Mass);
                }

                if (_shouldIJump)
                {
                    Body1.IsActive = true;
                    Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);

                    if (!BodyWalkingOn.IsStatic)
                    {
                        BodyWalkingOn.IsActive = true;
                        BodyWalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                    }
                }
            }
コード例 #6
0
        public override void Iterate()
        {
            deltaVelocity   = TargetVelocity - Body1.LinearVelocity;
            deltaVelocity.Y = 0.0f;

            // determine how 'stiff' the character follows the target velocity
            deltaVelocity *= this.Stiffness;

            if (deltaVelocity.LengthSquared() != 0.0f)
            {
                // activate it, in case it fall asleep :)
                Body1.IsActive = true;
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }

            if (shouldIJump)
            {
                Body1.IsActive = true;
                Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);

                if (!BodyWalkingOn.IsStatic)
                {
                    BodyWalkingOn.IsActive = true;
                    // apply the negative impulse to the other body
                    BodyWalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                }
            }
        }
コード例 #7
0
        public void RestapiOauthRevokePostTest()
        {
            // TODO: add unit test for the method 'RestapiOauthRevokePost'
            Body1 body = null; // TODO: replace null with proper value

            instance.RestapiOauthRevokePost(body);
        }
コード例 #8
0
    public override void Iterate()
    {
        deltaVelocity   = TargetVelocity - Body1.LinearVelocity;
        deltaVelocity.Y = 0.0f;

        deltaVelocity *= 0.02f;
        if (BodyWalkingOn == null)
        {
            deltaVelocity *= .1f;
        }

        if (deltaVelocity.LengthSquared() != 0.0f)
        {
            // activate it, in case it fall asleep :)
            Body1.IsActive = true;
            Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
        }

        if (shouldIJump)
        {
            Body1.IsActive = true;
            Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);

            if (!BodyWalkingOn.IsStatic)
            {
                BodyWalkingOn.IsActive = true;
                // apply the negative impulse to the other body
                BodyWalkingOn.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass, contactPoint);
            }
        }
    }
コード例 #9
0
ファイル: PrismaticJoint.cs プロジェクト: pabllopf/Alis
 /// <summary>
 ///     Set the joint limits, usually in meters.
 /// </summary>
 public void SetLimits(float lower, float upper)
 {
     Box2DxDebug.Assert(lower <= upper);
     Body1.WakeUp();
     Body2.WakeUp();
     LowerLimit = lower;
     UpperLimit = upper;
 }
コード例 #10
0
ファイル: TargetConstraint.cs プロジェクト: rumkex/Calcifer
        public override void Iterate()
        {
            var deltaVelocity = targetVelocity - Body1.LinearVelocity;

            if (deltaVelocity.LengthSquared() > 0.000001f)
            {
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }
        }
コード例 #11
0
        //
        // STATE FUNCTIONS
        //

        /// Adds force to residual R, as R*= F*c
        /// NOTE: here the off offset in R is NOT used because add F at the TWO offsets of the two connected bodies,
        /// so it is assumed that offsets for Body1 and Body2 variables have been already set properly!
        public override void IntLoadResidual_F(int off, ref ChVectorDynamic <double> R, double c)
        {
            if (Body1 == null || Body2 == null)
            {
                return;
            }

            ChVector mbody_force  = new ChVector(0, 0, 0);
            ChVector mbody_torque = new ChVector(0, 0, 0);

            if (ChVector.Vnotnull(C_force))
            {
                ChVector m_abs_force = Body2.GetA().Matr_x_Vect(marker2.FrameMoving.GetA().Matr_x_Vect(C_force));

                if (Body2.Variables().IsActive())
                {
                    Body2.To_abs_forcetorque(m_abs_force,
                                             marker1.GetAbsCoord().pos,          // absolute application point is always marker1
                                             false,                              // from abs. space
                                             ref mbody_force, ref mbody_torque); // resulting force-torque, both in abs coords
                    R.matrix.PasteSumVector(mbody_force * -c, Body2.Variables().GetOffset(), 0);
                    R.matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(mbody_torque) * -c,
                                            Body2.Variables().GetOffset() + 3, 0);
                }

                if (Body1.Variables().IsActive())
                {
                    Body1.To_abs_forcetorque(m_abs_force,
                                             marker1.GetAbsCoord().pos,          // absolute application point is always marker1
                                             false,                              // from abs. space
                                             ref mbody_force, ref mbody_torque); // resulting force-torque, both in abs coords
                    R.matrix.PasteSumVector(mbody_force * c, Body1.Variables().GetOffset(), 0);
                    R.matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(mbody_torque) * c,
                                            Body1.Variables().GetOffset() + 3, 0);
                }
            }
            if (ChVector.Vnotnull(C_torque))
            {
                ChVector m_abs_torque = Body2.GetA().Matr_x_Vect(marker2.FrameMoving.GetA().Matr_x_Vect(C_torque));
                // load torques in 'fb' vector accumulator of body variables (torques in local coords)
                if (Body1.Variables().IsActive())
                {
                    R.matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(m_abs_torque) * c,
                                            Body1.Variables().GetOffset() + 3, 0);
                }
                if (Body2.Variables().IsActive())
                {
                    R.matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(m_abs_torque) * -c,
                                            Body2.Variables().GetOffset() + 3, 0);
                }
            }
        }
コード例 #12
0
        /// Get the link coordinate system, expressed relative to Body2 (spherical side).
        /// This represents the 'main' reference of the link: reaction forces
        /// and reaction torques are reported in this coordinate system.
        public override ChCoordsys GetLinkRelativeCoords()
        {
            ChVector            pos1 = Body2.TransformPointParentToLocal(Body1.TransformPointLocalToParent(m_pos1));
            ChMatrix33 <double> A    = new ChMatrix33 <double>(0);

            ChVector u = (m_pos2 - pos1).GetNormalized();
            ChVector w = Body2.TransformDirectionParentToLocal(Body1.TransformDirectionLocalToParent(m_dir1));
            ChVector v = ChVector.Vcross(w, u);

            A.Set_A_axis(u, v, w);

            return(new ChCoordsys(pos1, A.Get_A_quaternion()));
        }
コード例 #13
0
        /// overwrites inherited implementation of this method
        public override void SetUpMarkers(ChMarker mark1, ChMarker mark2)
        {
            base.SetUpMarkers(mark1, mark2);

            // could the line below be:     assert(this.Body1 && this.Body2); ?
            if (this.Body1 != null && this.Body2 != null)
            {
                ((ChLinkMaskLF)this.mask).SetTwoBodiesVariables(Body1.Variables(), Body2.Variables());
                // This is needed because only if all constraints in mask are now active, and C,Ct,etc.
                // matrices must be allocated accordingly, otherwise are null.
                DestroyLink();
                BuildLink();
            }
        }
コード例 #14
0
        //
        // SOLVER INTERFACE (OLD)
        //
        public override void ConstraintsFbLoadForces(double factor = 1)
        {
            // compute instant torque
            double mT = m_func.Get_y(this.GetChTime());

            ChFrame <double> aframe1 = ChFrame <double> .BitShiftRight(this.frame1, (this.Body1));

            ChFrame <double> aframe2 = ChFrame <double> .BitShiftRight(this.frame2, (this.Body2));

            ChVector m_abs_torque = aframe2.GetA().Matr_x_Vect(new ChVector(0, 0, mT));

            Body2.Variables().Get_fb().matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(m_abs_torque) * -factor, 3, 0);

            Body1.Variables().Get_fb().matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(m_abs_torque) * factor, 3, 0);
        }
コード例 #15
0
        /// Get the link coordinate system, expressed relative to Body2 (the 'master'
        /// body). This represents the 'main' reference of the link: reaction forces
        /// are expressed in this coordinate system.
        /// (It is the coordinate system of the contact plane relative to Body2)
        public override ChCoordsys GetLinkRelativeCoords()
        {
            //ChVector D2local;
            ChVector D2temp = (ChVector.Vnorm(Body1.TransformPointLocalToParent(pos1) - Body2.TransformPointLocalToParent(pos2)));
            ChVector D2rel = Body2.TransformDirectionParentToLocal(D2temp);
            ChVector Vx = new ChVector(0, 0, 0), Vy = new ChVector(0, 0, 0), Vz = new ChVector(0, 0, 0);

            //ChMatrix33<double> rel_matrix = new ChMatrix33<double>();
            ChVector.XdirToDxDyDz(D2rel, ChVector.VECT_Y, ref Vx, ref Vy, ref Vz);
            rel_matrix.Set_A_axis(Vx, Vy, Vz);

            ChQuaternion Ql2 = rel_matrix.Get_A_quaternion();

            return(new ChCoordsys(pos2, Ql2));
        }
コード例 #16
0
        /// <summary>
        /// Asynchronously deserializes the given <paramref name="input"/> stream to an <see cref="AS4Message"/> model.
        /// </summary>
        /// <param name="input">The source stream from where the message should be read.</param>
        /// <param name="contentType">The content type required to correctly deserialize the message into different MIME parts.</param>
        /// <param name="cancellation">The token to control the cancellation of the deserialization.</param>
        public async Task <AS4Message> DeserializeAsync(
            Stream input,
            string contentType,
            CancellationToken cancellation = default(CancellationToken))
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (contentType == null)
            {
                throw new ArgumentNullException(nameof(contentType));
            }

            var envelopeDocument = new XmlDocument {
                PreserveWhitespace = true
            };

            envelopeDocument.Load(input);

            // Sometimes throws 'The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared.'
            // ValidateEnvelopeDocument(envelopeDocument);

            XmlNamespaceManager nsMgr = GetNamespaceManagerForDocument(envelopeDocument);

            SecurityHeader securityHeader  = DeserializeSecurityHeader(envelopeDocument, nsMgr);
            Messaging      messagingHeader = DeserializeMessagingHeader(envelopeDocument, nsMgr);
            Body1          body            = DeserializeBody(envelopeDocument, nsMgr);

            if (messagingHeader == null)
            {
                throw new InvalidMessageException("The envelopeStream does not contain a Messaging element");
            }

            AS4Message as4Message =
                await AS4Message.CreateAsync(
                    envelopeDocument,
                    contentType,
                    securityHeader,
                    messagingHeader,
                    body);

            StreamUtilities.MovePositionToStreamStart(input);

            return(as4Message);
        }
コード例 #17
0
        public static void Run()
        {
            var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1";
            var tokenId   = CreateInstrumentIdentifier.Run().Id;

            var requestObj = new Body1();

            var processingInformationObj = new Tmsv1instrumentidentifiersProcessingInformation();

            var authorizationOptionsObj = new Tmsv1instrumentidentifiersProcessingInformationAuthorizationOptions();

            var initiatorObj = new Tmsv1instrumentidentifiersProcessingInformationAuthorizationOptionsInitiator();

            var merchantInitiatedTransactionObj =
                new Tmsv1instrumentidentifiersProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction
            {
                PreviousTransactionId = "123456789012345"
            };

            initiatorObj.MerchantInitiatedTransaction = merchantInitiatedTransactionObj;

            authorizationOptionsObj.Initiator = initiatorObj;

            processingInformationObj.AuthorizationOptions = authorizationOptionsObj;

            requestObj.ProcessingInformation = processingInformationObj;

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new InstrumentIdentifierApi(clientConfig);

                var result = apiInstance.TmsV1InstrumentidentifiersTokenIdPatch(profileId, tokenId, requestObj);
                Console.WriteLine(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
コード例 #18
0
ファイル: PulleyJoint.cs プロジェクト: pabllopf/Alis
        /// <summary>
        ///     Initializes a new instance of the <see cref="PulleyJoint" /> class
        /// </summary>
        /// <param name="def">The def</param>
        public PulleyJoint(PulleyJointDef def)
            : base(def)
        {
            Ground        = Body1.GetWorld().GetGroundBody();
            GroundAnchor1 = def.GroundAnchor1 - Ground.GetXForm().Position;
            GroundAnchor2 = def.GroundAnchor2 - Ground.GetXForm().Position;
            LocalAnchor1  = def.LocalAnchor1;
            LocalAnchor2  = def.LocalAnchor2;

            Box2DxDebug.Assert(def.Ratio != 0.0f);
            Ratio = def.Ratio;

            Constant = def.Length1 + Ratio * def.Length2;

            MaxLength1 = Math.Min(def.MaxLength1, Constant - Ratio * MinPulleyLength);
            MaxLength2 = Math.Min(def.MaxLength2, (Constant - MinPulleyLength) / Ratio);

            Impulse       = 0.0f;
            LimitImpulse1 = 0.0f;
            LimitImpulse2 = 0.0f;
        }
コード例 #19
0
        public override void Iterate()
        {
            deltaVelocity = TargetVelocity - Body1.LinearVelocity;
            if (deltaVelocity.Y > 0 || isJumping)
            {
                deltaVelocity.Y = 0;
            }

            // determine how 'stiff' the character follows the target velocity
            deltaVelocity *= Stiff;

            if (deltaVelocity.LengthSquared() != 0.0f)
            {
                // activate it, in case it fall asleep :)
                Body1.IsActive = true;
                Body1.ApplyImpulse(deltaVelocity * Body1.Mass);
            }

            if (shouldIJump)
            {
                isJumping      = true;
                Body1.IsActive = true;
                Body1.ApplyImpulse(JumpVelocity * JVector.Up * Body1.Mass);
                System.Diagnostics.Debug.WriteLine("JUMP! " + DateTime.Now.Second.ToString());

                if (!BodyWalkingOn.IsStatic && World.RigidBodies.Contains(BodyWalkingOn))
                {
                    BodyWalkingOn.IsActive = true;
                    // apply the negative impulse to the other body
                    BodyWalkingOn.ApplyImpulse(-1.0f * JumpVelocity * JVector.Up * Body1.Mass);
                }
            }

            //if (!isJumping && !isGrounded)
            //    deltaVelocity.Y = -1.0f;

            //Text = isJumping + " " + shouldIJump;
        }
コード例 #20
0
        //
        // STATE FUNCTIONS
        //
        public override void IntLoadResidual_F(int off, ref ChVectorDynamic <double> R, double c)
        {
            // compute instant torque
            double mT = m_func.Get_y(this.GetChTime());

            ChFrame <double> aframe1 = ChFrame <double> .BitShiftRight(this.frame1, (this.Body1));

            ChFrame <double> aframe2 = ChFrame <double> .BitShiftRight(this.frame2, (this.Body2));

            ChVector m_abs_torque = aframe2.GetA().Matr_x_Vect(new ChVector(0, 0, mT));

            if (Body2.Variables().IsActive())
            {
                R.matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(m_abs_torque) * -c, Body2.Variables().GetOffset() + 3,
                                        0);
            }

            if (Body1.Variables().IsActive())
            {
                R.matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(m_abs_torque) * c, Body1.Variables().GetOffset() + 3,
                                        0);
            }
        }
コード例 #21
0
        //
        // SOLVER INTERFACE
        //

        /// Overrides the empty behaviour of the parent ChLink implementation, which
        /// does not consider any user-imposed force between the two bodies.
        /// It adds the current link-forces, if any, (caused by springs, etc.) to the 'fb' vectors
        /// of the ChVariables referenced by encapsulated ChConstraints.
        /// In details, it adds the effect caused by C_force and C_torque.
        /// Both C_force and C_torque these forces are considered expressed in the
        /// reference coordsystem of marker2 (the MAIN marker),
        /// and their application point is the origin of marker1 (the SLAVE marker).
        public override void ConstraintsFbLoadForces(double factor = 1)
        {
            if (Body1 == null || Body2 == null)
            {
                return;
            }

            ChVector mbody_force  = new ChVector(0, 0, 0);
            ChVector mbody_torque = new ChVector(0, 0, 0);

            if (ChVector.Vnotnull(C_force))
            {
                ChVector m_abs_force = Body2.GetA().Matr_x_Vect(marker2.FrameMoving.GetA().Matr_x_Vect(C_force));
                Body2.To_abs_forcetorque(m_abs_force,
                                         marker1.GetAbsCoord().pos,          // absolute application point is always marker1
                                         false,                              // from abs. space
                                         ref mbody_force, ref mbody_torque); // resulting force-torque, both in abs coords
                Body2.Variables().Get_fb().matrix.PasteSumVector(mbody_force * -factor, 0, 0);
                Body2.Variables().Get_fb().matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(mbody_torque) * -factor, 3,
                                                                 0);

                Body1.To_abs_forcetorque(m_abs_force,
                                         marker1.GetAbsCoord().pos,          // absolute application point is always marker1
                                         false,                              // from abs. space
                                         ref mbody_force, ref mbody_torque); // resulting force-torque, both in abs coords
                Body1.Variables().Get_fb().matrix.PasteSumVector(mbody_force * factor, 0, 0);
                Body1.Variables().Get_fb().matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(mbody_torque) * factor, 3, 0);
            }
            if (ChVector.Vnotnull(C_torque))
            {
                ChVector m_abs_torque = Body2.GetA().Matr_x_Vect(marker2.FrameMoving.GetA().Matr_x_Vect(C_torque));
                // load torques in 'fb' vector accumulator of body variables (torques in local coords)
                Body1.Variables().Get_fb().matrix.PasteSumVector(Body1.TransformDirectionParentToLocal(m_abs_torque) * factor, 3, 0);
                Body2.Variables().Get_fb().matrix.PasteSumVector(Body2.TransformDirectionParentToLocal(m_abs_torque) * -factor, 3,
                                                                 0);
            }
        }
コード例 #22
0
        public override void Iterate()
        {
            if (Rotate == Rotate.Clockwise)
            {
                Body1.IsActive = true;
                JVector torque = new JVector(0, 0, 1);
                torque = JVector.Transform(torque, Body1.Orientation);
                torque = JVector.Transform(torque, Body1.Inertia);
                Body1.AddTorque(torque * Body1.Mass);
            }

            if (Rotate == Rotate.Anticlockwise)
            {
                Body1.IsActive = true;
                JVector torque = new JVector(0, 0, -1);
                torque = JVector.Transform(torque, Body1.Orientation);
                torque = JVector.Transform(torque, Body1.Inertia);
                Body1.AddTorque(torque * Body1.Mass);
            }

            if (Direction == Walk.Forward)
            {
                Body1.IsActive = true;
                JVector force = new JVector(1, 0, 0);
                force = JVector.Transform(force, Body1.Orientation);
                Body1.AddForce(force * Body1.Mass);
            }

            if (Direction == Walk.Backward)
            {
                Body1.IsActive = true;
                JVector force = new JVector(-1, 0, 0);
                force = JVector.Transform(force, Body1.Orientation);
                Body1.AddForce(force * Body1.Mass);
            }
        }
コード例 #23
0
 public void Init()
 {
     instance = new Body1();
 }
        /// <summary>
        /// trace Trace
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <param name="token"></param>
        /// <param name="serverWebAdaptor"></param>
        /// <param name="utilityNetworkName"></param>
        /// <returns>Task of ApiResponse (TraceResultsSet)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <TraceResultsSet> > TraceAsyncWithHttpInfo(Body1 body, string token, string serverWebAdaptor, string utilityNetworkName)
        {
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling UtilityNetworkServiceApi->Trace");
            }
            // verify the required parameter 'token' is set
            if (token == null)
            {
                throw new ApiException(400, "Missing required parameter 'token' when calling UtilityNetworkServiceApi->Trace");
            }
            // verify the required parameter 'serverWebAdaptor' is set
            if (serverWebAdaptor == null)
            {
                throw new ApiException(400, "Missing required parameter 'serverWebAdaptor' when calling UtilityNetworkServiceApi->Trace");
            }
            // verify the required parameter 'utilityNetworkName' is set
            if (utilityNetworkName == null)
            {
                throw new ApiException(400, "Missing required parameter 'utilityNetworkName' when calling UtilityNetworkServiceApi->Trace");
            }

            var    localVarPath         = "/{ServerWebAdaptor}/rest/services/{UtilityNetworkName}/UtilityNetworkServer/trace";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (serverWebAdaptor != null)
            {
                localVarPathParams.Add("ServerWebAdaptor", this.Configuration.ApiClient.ParameterToString(serverWebAdaptor));                           // path parameter
            }
            if (utilityNetworkName != null)
            {
                localVarPathParams.Add("UtilityNetworkName", this.Configuration.ApiClient.ParameterToString(utilityNetworkName));                             // path parameter
            }
            if (token != null)
            {
                localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "token", token));                // query parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("Trace", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <TraceResultsSet>(localVarStatusCode,
                                                     localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
                                                     (TraceResultsSet)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(TraceResultsSet))));
        }
        /// <summary>
        /// trace Trace
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <param name="token"></param>
        /// <param name="serverWebAdaptor"></param>
        /// <param name="utilityNetworkName"></param>
        /// <returns>Task of TraceResultsSet</returns>
        public async System.Threading.Tasks.Task <TraceResultsSet> TraceAsync(Body1 body, string token, string serverWebAdaptor, string utilityNetworkName)
        {
            ApiResponse <TraceResultsSet> localVarResponse = await TraceAsyncWithHttpInfo(body, token, serverWebAdaptor, utilityNetworkName);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// trace Trace
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body"></param>
        /// <param name="token"></param>
        /// <param name="serverWebAdaptor"></param>
        /// <param name="utilityNetworkName"></param>
        /// <returns>TraceResultsSet</returns>
        public TraceResultsSet Trace(Body1 body, string token, string serverWebAdaptor, string utilityNetworkName)
        {
            ApiResponse <TraceResultsSet> localVarResponse = TraceWithHttpInfo(body, token, serverWebAdaptor, utilityNetworkName);

            return(localVarResponse.Data);
        }
コード例 #27
0
        /// <summary>
        /// Modify a Loadbalancer You can use update attributes of a resource
        /// </summary>
        /// <param name="datacenterId"></param>
        /// <param name="loadbalancerId"></param>
        /// <param name="loadbalancer">Modified Loadbalancer</param>
        /// <param name="body"></param>
        /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param>
        /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param>
        /// <returns>Task of ApiResponse (Loadbalancer)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Loadbalancer>> UpdateAsyncWithHttpInfo(string datacenterId, string loadbalancerId, Loadbalancer loadbalancer, Body1 body = null, bool? parameter = null, int? depth = null)
        {
            // verify the required parameter 'datacenterId' is set
            if (datacenterId == null) throw new ApiException(400, "Missing required parameter 'datacenterId' when calling Update");
            // verify the required parameter 'loadbalancerId' is set
            if (loadbalancerId == null) throw new ApiException(400, "Missing required parameter 'loadbalancerId' when calling Update");
            // verify the required parameter 'loadbalancer' is set
            if (loadbalancer == null) throw new ApiException(400, "Missing required parameter 'loadbalancer' when calling Update");


            var path_ = "/datacenters/{datacenterId}/loadbalancers/{loadbalancerId}";

            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json", "application/vnd.profitbricks.resource+json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/vnd.profitbricks.resource+json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (datacenterId != null) pathParams.Add("datacenterId", Configuration.ApiClient.ParameterToString(datacenterId)); // path parameter
            if (loadbalancerId != null) pathParams.Add("loadbalancerId", Configuration.ApiClient.ParameterToString(loadbalancerId)); // path parameter

            if (parameter != null) queryParams.Add("parameter", Configuration.ApiClient.ParameterToString(parameter)); // query parameter
            if (depth != null) queryParams.Add("depth", Configuration.ApiClient.ParameterToString(depth)); // query parameter



            postBody = Configuration.ApiClient.Serialize(loadbalancer); // http body (model) parameter



            // authentication (basicAuth) required

            // http basic authentication required
            if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
            {
                headerParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
            }


            // make the HTTP request
            IRestResponse response = (IRestResponse)await Configuration.ApiClient.CallApiAsync(path_,
                Method.PUT, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int)response.StatusCode;

            if (statusCode >= 400)
                throw new ApiException(statusCode, "Error calling Update: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException(statusCode, "Error calling Update: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<Loadbalancer>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Loadbalancer)Configuration.ApiClient.Deserialize(response, typeof(Loadbalancer)));

        }
コード例 #28
0
ファイル: PrismaticJoint.cs プロジェクト: pabllopf/Alis
 /// <summary>
 ///     Set the maximum motor force, usually in N.
 /// </summary>
 public void SetMaxMotorForce(float force)
 {
     Body1.WakeUp();
     Body2.WakeUp();
     MaxMotorForce = Settings.FORCE_SCALE(1.0f) * force;
 }
コード例 #29
0
ファイル: PrismaticJoint.cs プロジェクト: pabllopf/Alis
 /// <summary>
 ///     Enable/disable the joint motor.
 /// </summary>
 public void EnableMotor(bool flag)
 {
     Body1.WakeUp();
     Body2.WakeUp();
     IsMotorEnabled = flag;
 }
コード例 #30
0
 /// <summary>
 /// Modify a Loadbalancer You can use update attributes of a resource
 /// </summary>
 /// <param name="datacenterId"></param> 
 /// <param name="loadbalancerId"></param> 
 /// <param name="loadbalancer">Modified Loadbalancer</param> 
 /// <param name="body"></param> 
 /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> 
 /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param> 
 /// <returns>Loadbalancer</returns>
 public Loadbalancer Update(string datacenterId, string loadbalancerId, Loadbalancer loadbalancer, Body1 body = null, bool? parameter = null, int? depth = null)
 {
     ApiResponse<Loadbalancer> response = UpdateWithHttpInfo(datacenterId, loadbalancerId, loadbalancer, body, parameter, depth);
     return response.Data;
 }
コード例 #31
0
ファイル: PrismaticJoint.cs プロジェクト: pabllopf/Alis
 /// <summary>
 ///     Enable/disable the joint limit.
 /// </summary>
 public void EnableLimit(bool flag)
 {
     Body1.WakeUp();
     Body2.WakeUp();
     IsLimitEnabled = flag;
 }
コード例 #32
0
 /// <summary>
 ///     Set the motor speed, usually in meters per second.
 /// </summary>
 public void SetMotorSpeed(float speed)
 {
     Body1.WakeUp();
     Body2.WakeUp();
     MotorSpeed = speed;
 }
コード例 #33
0
        /// <summary>
        /// Modify a Loadbalancer You can use update attributes of a resource
        /// </summary>
        /// <param name="datacenterId"></param>
        /// <param name="loadbalancerId"></param>
        /// <param name="loadbalancer">Modified Loadbalancer</param>
        /// <param name="body"></param>
        /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param>
        /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param>
        /// <returns>Task of Loadbalancer</returns>
        public async System.Threading.Tasks.Task<Loadbalancer> UpdateAsync(string datacenterId, string loadbalancerId, Loadbalancer loadbalancer, Body1 body = null, bool? parameter = null, int? depth = null)
        {
            ApiResponse<Loadbalancer> response = await UpdateAsyncWithHttpInfo(datacenterId, loadbalancerId, loadbalancer, body, parameter, depth);
            return response.Data;

        }