public void addScaledVector(MyVector3 vector, real scale)
        {
            MyQuaternion q = new MyQuaternion(0,
                                              vector.x * scale,
                                              vector.y * scale,
                                              vector.z * scale);

            q *= this;
            r += q.r * ((real)0.5);
            i += q.i * ((real)0.5);
            j += q.j * ((real)0.5);
            k += q.k * ((real)0.5);
        }
Exemplo n.º 2
0
        public void ReplyTest()
        {
            bridgeForum forum = new real();

            Rooney(forum);
            forum.addPost("Manchester United", "Champ19ns", "thropy", "i got my 10 thropy", "vida", "15");
            forum.reply("Manchester United", "Champ19ns", "i got my 10 thropy", "assists", "and i have 5", "wazza", "10");
            IList <string> lst = forum.AllPostreplies("Manchester United", "Champ19ns", "i got my 10 thropy", "wazza", "10");

            Assert.AreEqual(lst.Count, 1, 0, "there is only one reply");
            //Assert.AreEqual(lst.Exists(element => element.Equals("and i have 5")), true, "assists is only one reply");
            RooneyDis(forum);
        }
Exemplo n.º 3
0
        public void CreateSubForumTest()
        {
            bridgeForum forum = new real();

            Rooney(forum);
            List <string> lst = forum.subForumList("Manchester United");

            Assert.AreEqual(lst.Count, 1, 0, "there is only one sub forum");
            Assert.AreEqual(lst.Exists(element => element.Equals("Champ19ns")), true, "Champ19ns is only one sub");
            bool b = forum.createSubForum("Manchester United", "Champions 20", "new record: 19 primer league titles", "vida", "wazza", "10");

            Assert.AreEqual(b, false, "wazza cant create sub forum");
        }
Exemplo n.º 4
0
        public void InitTest() //use case 1
        {
            bridgeForum system = new real();

            system.init("Ferguson", "scottishAccent", "alex@fer", "fergi", "england.manchster");
            // allowed to perform actions after initialization
            Boolean added = system.createForum("Ferguson", "scottishAccent", "First Forum", 2);

            Assert.IsTrue(added);

            added = system.createSubForum("First Forum", "First Thread", "SubForumSubject", "", "Ferguson", "scottishAccent");
            Assert.IsTrue(added);
        }
Exemplo n.º 5
0
 public void setAwake(bool awake = true)
 {
     if (awake)
     {
         isAwake = true;
         motion  = sleepEpsilon * 2.0f;
     }
     else
     {
         isAwake = false;
         velocity.Clear();
         rotation.Clear();
     }
 }
Exemplo n.º 6
0
        public void AnonymousConnectTest()
        {
            bridgeForum system = new real();

            system.init("Ferguson", "scottishAccent", "*****@*****.**", "alex ferguson", "england.manchster");
            system.createForum("Ferguson", "scottishAccent", "First Forum", 2);
            system.createSubForum("First Forum", "First Thread", "SubForumSubject", "", "Ferguson", "scottishAccent");
            system.createSubForum("First Forum", "Second Thread", "SubForumSubject2", "", "Ferguson", "scottishAccent");
            IList <string> listSubForums     = system.subForumList("First Forum");
            IList <string> recievedSubForums = system.anonymousConnect("First Forum");

            Assert.AreEqual(recievedSubForums.Count, 2, "guest recieved a list of two sub forums");
            // Assert.IsTrue(listSubForums.Equals(recievedSubForums));
        }
Exemplo n.º 7
0
        public void DeletePostTest()
        {
            bridgeForum forum = new real();

            Rooney(forum);
            forum.addPost("Manchester United", "Champ19ns", "thropy", "i got my 10 thropy", "vida", "15");
            forum.deletePost("wazza", "10", "Manchester United", "Champ19ns", "thropy", "i got my 10 thropy");
            Assert.AreEqual(forum.postsList("Manchester United", "Champ19ns").Count, 1, 0, "normal member cant remove this post");
            forum.addPost("Manchester United", "Champ19ns", "assists", "i am with 19 asissts", "wazza", "10");
            forum.deletePost("wazza", "10", "Manchester United", "Champ19ns", "assists", "i am with 19 asissts");
            Assert.AreEqual(forum.postsList("Manchester United", "Champ19ns").Count, 1, 0, "normal member remove his post");
            forum.deletePost("giggsy", "11", "Manchester United", "Champ19ns", "thropy", "i got my 10 thropy");
            Assert.AreEqual(forum.postsList("Manchester United", "Champ19ns").Count, 0, 0, "giggsy can do everything");
            RooneyDis(forum);
        }
Exemplo n.º 8
0
        public static boolean IsUnitInRangeLoc(unit whichUnit, location whichLocation, real distance)
        {
            real xs = whichUnit.x - whichLocation.x;
            real ys = whichUnit.y - whichLocation.y;
            real d  = (real)Math.Sqrt(xs * xs + ys * ys);

            if (distance >= d)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 9
0
        public static boolean IsUnitInRangeXY(unit whichUnit, real x, real y, real distance)
        {
            real xs = whichUnit.x - x;
            real ys = whichUnit.y - y;
            real d  = (real)Math.Sqrt(xs * xs + ys * ys);

            if (distance >= d)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 10
0
        public void DeleteCommentPostTest()
        {
            bridgeForum forum = new real();

            Rooney(forum);
            forum.addPost("Manchester United", "Champ19ns", "assists", "i am with 19 asissts", "wazza", "10");
            forum.reply("Manchester United", "Champ19ns", "i am with 19 asissts", "a", "and 20 goals", "wazza", "10");
            IList <string> lst = forum.AllPostreplies("Manchester United", "Champ19ns", "i am with 19 asissts", "wazza", "10");

            Assert.AreEqual(1, lst.Count, "there is one comment");
            forum.deletePost("wazza", "10", "Manchester United", "Champ19ns", "a", "and 20 goals");
            IList <string> lst1 = forum.AllPostreplies("Manchester United", "Champ19ns", "i am with 19 asissts", "wazza", "10");

            Assert.AreEqual(0, lst1.Count, "there is no comments");
            RooneyDis(forum);
        }
Exemplo n.º 11
0
        public void MailConfirmTest()
        {
            bridgeForum forum = new real();

            Rooney(forum);
            forum.addPost("Manchester United", "Champ19ns", "thropy", "i got my 10 thropy", "vida", "15");

            List <string> lst = forum.subForumPosts("wazza", "10", "Manchester United", "Champ19ns");

            Assert.AreEqual(lst.Count, 1, 0, "there is only one post");
            Int64 i = forum.register("Manchester United", "wazza", "10", "wayne rooney", "*****@*****.**");

            forum.mailConfirm("wazza", "10", "Manchester United", i);
            Assert.IsFalse(forum.memberConnect("Manchester United", "wazza", "10"));
            RooneyDis(forum);
        }
Exemplo n.º 12
0
        public void PromoteMemberToModeratorTest()
        {
            bridgeForum forum = new real();

            Rooney(forum);
            List <string> lst = forum.subForumModerators("giggsy", "11", "Manchester United", "Champ19ns");

            Assert.AreEqual(lst.Count, 1, 0, "there is only one moderator");
            Assert.AreEqual(lst.Exists(element => element.Equals("vida")), true, "vida is only one moderator");

            forum.promoteMemberToModerator("giggsy", "11", "Manchester United", "wazza", "Champ19ns");
            lst = forum.subForumModerators("giggsy", "11", "Manchester United", "Champ19ns");
            Assert.AreEqual(lst.Count, 2, 0, "now there is two moderators");
            Assert.AreEqual(lst.Exists(element => element.Equals("wazza")), true, "wazza is one of them moderator");
            RooneyDis(forum);
        }
Exemplo n.º 13
0
        public void normalise()
        {
            real d = r * r + i * i + j * j + k * k;

            if (d < Mathf.Epsilon)
            {
                r = 1;
                return;
            }

            d  = ((real)1.0) / Mathf.Sqrt((float)d);
            r *= d;
            i *= d;
            j *= d;
            k *= d;
        }
Exemplo n.º 14
0
        public void ChangePolicyTest()
        {
            bridgeForum system = new real();

            system.init("Ferguson", "scottishAccent", "alex@fer", "fergi", "england.manchster");
            system.createForum("Ferguson", "scottishAccent", "First Forum", 2);
            Boolean changed = true;//system.changePolicy("Ferguson", "scottishAccent", "First Forum", 1);

            Assert.IsTrue(changed);

            changed = false;// system.changePolicy("Ferguson", "wrong pass", "First Forum", 1); // wrong password-> wont change policy
            Assert.IsFalse(changed);

            system.register("First Forum", "user1", "I Hate Football", "Ronaldo", "*****@*****.**");
            changed = false;
            //system.changePolicy("user1", "I Hate Football", "First Forum", 1); // simple member-> wont change policy
            Assert.IsFalse(changed);
        }
Exemplo n.º 15
0
 public RigidBody()
 {
     this.inverseMass               = new real();
     this.inverseInertiaTensor      = new Matrix3();
     this.linearDamping             = new real();
     this.angularDamping            = new real();
     this.position                  = new MyVector3();
     this.orientation               = new MyQuaternion();
     this.velocity                  = new MyVector3();
     this.rotation                  = new MyVector3();
     this.inverseInertiaTensorWorld = new Matrix3();
     this.motion                = new real();
     this.isAwake               = new bool();
     this.canSleep              = new bool();
     this.transformMatrix       = new Matrix4();
     this.forceAccum            = new MyVector3();
     this.torqueAccum           = new MyVector3();
     this.acceleration          = new MyVector3();
     this.lastFrameAcceleration = new MyVector3();
 }
Exemplo n.º 16
0
 public void Read_type()
 {
     this.PLC.ReadClass(this, this.DB, this.DBB);
     try
     {
         real real_tag = this.rte.real.Find(this.DB, this.DBB);
         {
             real_tag.Value = this.value;
             real_log rl = new real_log
             {
                 name  = real_tag.name,
                 value = (float)real_tag.Value,
                 TIME  = DateTime.Now,
             };
             rte.real_log.Add(rl);
             this.rte.SaveChanges();
         }
     }catch (Exception ex)
     {
         MessageBox.Show(ex.InnerException.ToString());
     }
 }
Exemplo n.º 17
0
        /**
         * Integrates the rigid body forward in time by the given amount.
         * This function uses a Newton-Euler integration method
         */
        public void integrate(real duration)
        {
            if (!isAwake)
            {
                return;
            }

            lastFrameAcceleration = acceleration;
            lastFrameAcceleration.AddScaledVector(forceAccum, inverseMass);
            MyVector3 angularAcceleration = inverseInertiaTensorWorld.transform(torqueAccum);

            velocity.AddScaledVector(lastFrameAcceleration, duration);
            rotation.AddScaledVector(angularAcceleration, duration);
            velocity *= Mathf.Pow((float)linearDamping, (float)duration);
            rotation *= Mathf.Pow((float)angularDamping, (float)duration);
            position.AddScaledVector(velocity, duration);
            orientation.addScaledVector(rotation, duration);
            calculateDerivedData();
            clearAccumulators();

            if (canSleep)
            {
                real currentMotion = velocity.ScalarProduct(velocity) +
                                     rotation.ScalarProduct(rotation);

                real bias = Mathf.Pow(0.5f, (float)duration);
                motion = bias * motion + (1 - bias) * currentMotion;

                if (motion < sleepEpsilon)
                {
                    setAwake(false);
                }
                else if (motion > 10 * sleepEpsilon)
                {
                    motion = 10 * sleepEpsilon;
                }
            }
        }
Exemplo n.º 18
0
        public void SubForumListTest()
        {
            bridgeForum forum = new real();

            forum.init("Ferguson", "scottishAccent", "*****@*****.**", "alex ferguson", "england.manchster");
            forum.SPlogin("Ferguson", "scottishAccent");
            forum.createForum("Ferguson", "scottishAccent", "Manchester United", 5);
            Int64 i = forum.register("Manchester United", "giggsy", "11", "ryan giggs", "*****@*****.**");

            forum.mailConfirm("giggsy", "11", "Manchester United", i);
            i = forum.register("Manchester United", "vida", "15", "Nemanja Vidić", "*****@*****.**");
            forum.mailConfirm("vida", "15", "Manchester United", i);
            forum.memberConnect("Manchester United", "Ferguson", "scottishAccent");    forum.promoteMemberToAdmin("Ferguson", "scottishAccent", "Manchester United", "giggsy");
            forum.memberConnect("Manchester United", "giggsy", "11");

            forum.memberConnect("Manchester United", "vida", "15");
            forum.createSubForum("Manchester United", "Champ19ns", "new record: 19 primer league titles", "vida", "giggsy", "11");

            IList <string> lst = forum.subForumList("Manchester United");

            Assert.AreEqual(lst.Count, 1, 0, "there is only one sub forum");
            //Assert.AreEqual(lst.Exists(element => element.Equals("Champ19ns")), true, "Champ19ns is only one sub");
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            bridgeForum forum = new real();

            forum.init("Ferguson", "scottishAccent", "*****@*****.**", "alex ferguson", "england.manchster");
            forum.createForum("Ferguson", "scottishAccent", "Manchester United", 5);
            Int64 i = forum.register("Manchester United", "giggsy", "11", "ryan giggs", "*****@*****.**");

            forum.mailConfirm("giggsy", "11", "Manchester United", i);
            i = forum.register("Manchester United", "vida", "15", "Nemanja Vidić", "*****@*****.**");
            forum.mailConfirm("vida", "15", "Manchester United", i);
            forum.memberConnect("Manchester United", "Ferguson", "scottishAccent");
            forum.promoteMemberToAdmin("Ferguson", "scottishAccent", "Manchester United", "giggsy");
            forum.memberConnect("Manchester United", "giggsy", "11");

            forum.memberConnect("Manchester United", "vida", "15");
            forum.createSubForum("Manchester United", "Champ19ns", "new record: 19 primer league titles", "vida", "giggsy", "11");
            i = forum.register("Manchester United", "wazza", "10", "wayne rooney", "*****@*****.**");
            forum.mailConfirm("wazza", "10", "Manchester United", i);
            forum.memberConnect("Manchester United", "wazza", "10");

            forum.addPost("Manchester United", "Champ19ns", "thropy", "i got my 10 thropy", "vida", "15");
            forum.deletePost("wazza", "10", "Manchester United", "Champ19ns", "thropy", "i got my 10 thropy");
            // Assert.AreEqual(forum.postsList("Manchester United", "Champ19ns").Count, 1, 0, "normal member cant remove this post");
            forum.addPost("Manchester United", "Champ19ns", "assists", "i am with 19 asissts", "wazza", "10");
            forum.deletePost("wazza", "10", "Manchester United", "Champ19ns", "assists", "i am with 19 asissts");
            int x = forum.postsList("Manchester United", "Champ19ns").Count;

            //   Assert.AreEqual(x, 1, "normal member remove his post");
            forum.deletePost("giggsy", "11", "Manchester United", "Champ19ns", "thropy", "i got my 10 thropy");
            //  Assert.AreEqual(forum.postsList("Manchester United", "Champ19ns").Count, 0, 0, "giggsy can do everything");
            forum.memberDisConnect("Manchester United", "wazza", "10");
            forum.memberDisConnect("Manchester United", "vida", "15");
            forum.memberDisConnect("Manchester United", "giggsy", "11");
            forum.memberDisConnect("Manchester United", "Ferguson", "scottishAccent");
        }
Exemplo n.º 20
0
        public void CreateForumTest() //use case 2
        {
            bridgeForum system = new real();

            system.init("Ferguson", "scottishAccent", "alex@fer", "fergi", "england.manchster");
            system.createForum("Ferguson", "scottishAccent", "First Forum", 2);
            List <string> listOfForums = system.forumList();

            Assert.AreEqual(listOfForums.Count, 1, 0, "one forum created since initialization, as wanted");
            system.createForum("Ferguson", "scottishAccent", "Second Forum", 1);
            listOfForums = system.forumList();
            Assert.AreEqual(listOfForums.Count, 2, 0, "two forums created since initialization, as wanted");

            system.createForum("wrongUserName", "scottishAccent", "Third Forum", 2); //wrong user name: should not add forum
            listOfForums = system.forumList();
            Assert.AreEqual(listOfForums.Count, 2, 0, "two forums created since initialization, as wanted");

            // check: super manager member in forumro
            system.createSubForum("First Forum", "First Thread", "SubForumSubject", "", "Ferguson", "scottishAccent");
            system.memberConnect("First Forum", "Ferguson", "scottishAccent");
            Boolean added = system.addPost("First Forum", "First Thread", "Post subject", "Amir!best rommate ever ;)", "Ferguson", "scottishAccent");

            Assert.IsTrue(added);
        }
Exemplo n.º 21
0
 public void setAcceleration(real x, real y, real z)
 {
     acceleration.x = x;
     acceleration.y = y;
     acceleration.z = z;
 }
Exemplo n.º 22
0
 public void setRotation(real x, real y, real z)
 {
     rotation.x = x;
     rotation.y = y;
     rotation.z = z;
 }
Exemplo n.º 23
0
 public void setVelocity(real x, real y, real z)
 {
     velocity.x = x;
     velocity.y = y;
     velocity.z = z;
 }
Exemplo n.º 24
0
 public void setPosition(real x, real y, real z)
 {
     position.x = x;
     position.y = y;
     position.z = z;
 }
Exemplo n.º 25
0
 /**
  * Sets the angular damping for the rigid body.
  * angularDamping The speed that rotation is shed from
  * the rigid body.
  */
 public void setAngularDamping(real angularDamping)
 {
     this.angularDamping = angularDamping;
 }
Exemplo n.º 26
0
 /**
  * Sets the linear damping for the rigid body.
  * linearDamping The speed that velocity is shed from
  * the rigid body.
  */
 public void setLinearDamping(real linearDamping)
 {
     this.linearDamping = linearDamping;
 }
Exemplo n.º 27
0
 public void setDamping(real linearDamping, real angularDamping)
 {
     this.linearDamping  = linearDamping;
     this.angularDamping = angularDamping;
 }
Exemplo n.º 28
0
 public void setInverseMass(real inverseMass)
 {
     this.inverseMass = inverseMass;
 }
Exemplo n.º 29
0
 public void setMass(real mass)
 {
     Debug.Assert(mass != 0);
     this.inverseMass = ((real)1.0) / mass;
 }
Exemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComplexF"/> struct.
 /// </summary>
 /// <param name="real">The real part.</param>
 /// <param name="imaginary">The imaginary part.</param>
 public ComplexF(float real, float imaginary) => value = new Vector2(real, imaginary);