当前位置: 首页>>代码示例>>C#>>正文


C# Vec2.length方法代码示例

本文整理汇总了C#中Vec2.length方法的典型用法代码示例。如果您正苦于以下问题:C# Vec2.length方法的具体用法?C# Vec2.length怎么用?C# Vec2.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vec2的用法示例。


在下文中一共展示了Vec2.length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: op

 public float op(Vec2 argVec)
 {
     argVec.set(MathUtils.randomFloat(-100, 100), MathUtils.randomFloat(-100, 100));
     argVec.mulLocal(3.2f);
     float s = argVec.length();
     argVec.normalize();
     return s;
 }
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:8,代码来源:StackTest.cs

示例2: initTest

        public override void initTest(bool argDeserialized)
        {
            Body ground = null;
            {
                BodyDef bd = new BodyDef();
                ground = getWorld().createBody(bd);

                EdgeShape shape = new EdgeShape();
                shape.set(new Vec2(-40.0f, 0.0f), new Vec2(40.0f, 0.0f));
                ground.createFixture(shape, 0.0f);
            }

            {
                PolygonShape shape = new PolygonShape();
                shape.setAsBox(0.5f, 0.5f);

                BodyDef bd = new BodyDef();
                bd.type = BodyType.DYNAMIC;

                bd.position.set(-5.0f, 5.0f);
                m_bodies[0] = getWorld().createBody(bd);
                m_bodies[0].createFixture(shape, 5.0f);

                bd.position.set(5.0f, 5.0f);
                m_bodies[1] = getWorld().createBody(bd);
                m_bodies[1].createFixture(shape, 5.0f);

                bd.position.set(5.0f, 15.0f);
                m_bodies[2] = getWorld().createBody(bd);
                m_bodies[2].createFixture(shape, 5.0f);

                bd.position.set(-5.0f, 15.0f);
                m_bodies[3] = getWorld().createBody(bd);
                m_bodies[3].createFixture(shape, 5.0f);

                DistanceJointDef jd = new DistanceJointDef();
                Vec2 p1 = new Vec2();
                Vec2 p2 = new Vec2();
                Vec2 d = new Vec2();

                jd.frequencyHz = 4.0f;
                jd.dampingRatio = 0.5f;

                jd.bodyA = ground;
                jd.bodyB = m_bodies[0];
                jd.localAnchorA.set(-10.0f, 0.0f);
                jd.localAnchorB.set(-0.5f, -0.5f);
                p1 = jd.bodyA.getWorldPoint(jd.localAnchorA);
                p2 = jd.bodyB.getWorldPoint(jd.localAnchorB);
                d = p2.sub(p1);
                jd.length = d.length();
                m_joints[0] = getWorld().createJoint(jd);

                jd.bodyA = ground;
                jd.bodyB = m_bodies[1];
                jd.localAnchorA.set(10.0f, 0.0f);
                jd.localAnchorB.set(0.5f, -0.5f);
                p1 = jd.bodyA.getWorldPoint(jd.localAnchorA);
                p2 = jd.bodyB.getWorldPoint(jd.localAnchorB);
                d = p2.sub(p1);
                jd.length = d.length();
                m_joints[1] = getWorld().createJoint(jd);

                jd.bodyA = ground;
                jd.bodyB = m_bodies[2];
                jd.localAnchorA.set(10.0f, 20.0f);
                jd.localAnchorB.set(0.5f, 0.5f);
                p1 = jd.bodyA.getWorldPoint(jd.localAnchorA);
                p2 = jd.bodyB.getWorldPoint(jd.localAnchorB);
                d = p2.sub(p1);
                jd.length = d.length();
                m_joints[2] = getWorld().createJoint(jd);

                jd.bodyA = ground;
                jd.bodyB = m_bodies[3];
                jd.localAnchorA.set(-10.0f, 20.0f);
                jd.localAnchorB.set(-0.5f, 0.5f);
                p1 = jd.bodyA.getWorldPoint(jd.localAnchorA);
                p2 = jd.bodyB.getWorldPoint(jd.localAnchorB);
                d = p2.sub(p1);
                jd.length = d.length();
                m_joints[3] = getWorld().createJoint(jd);

                jd.bodyA = m_bodies[0];
                jd.bodyB = m_bodies[1];
                jd.localAnchorA.set(0.5f, 0.0f);
                jd.localAnchorB.set(-0.5f, 0.0f);
                ;
                p1 = jd.bodyA.getWorldPoint(jd.localAnchorA);
                p2 = jd.bodyB.getWorldPoint(jd.localAnchorB);
                d = p2.sub(p1);
                jd.length = d.length();
                m_joints[4] = getWorld().createJoint(jd);

                jd.bodyA = m_bodies[1];
                jd.bodyB = m_bodies[2];
                jd.localAnchorA.set(0.0f, 0.5f);
                jd.localAnchorB.set(0.0f, -0.5f);
                p1 = jd.bodyA.getWorldPoint(jd.localAnchorA);
                p2 = jd.bodyB.getWorldPoint(jd.localAnchorB);
//.........这里部分代码省略.........
开发者ID:Nomad1,项目名称:sharpbox2d,代码行数:101,代码来源:Web.cs


注:本文中的Vec2.length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。