Ejemplo n.º 1
0
        /// <summary>
        /// Link状態の時、FormMainから呼ばれる。rotにもっとも近い回転行列をExperimetal coordinatesの
        /// オイラー角で表現する。その後、この回転行列で他のウィンドウに回転命令を出す。
        /// </summary>
        /// <param name="rot"></param>
        public void setRotation(Matrix3D rot)
        {
            var settings = new List <(V3 Vec, double Angle, bool Variable)>();
            var dir      = getExpDirections();

            settings.Add((dir[0], numericBoxExp1.RadianValue, !checkBoxFix1st.Checked));
            if (checkBoxEnable2nd.Checked)
            {
                settings.Add((dir[1], numericBoxExp2.RadianValue, !checkBoxFix2nd.Checked));
            }
            if (checkBoxEnable3rd.Checked)
            {
                settings.Add((dir[2], numericBoxExp3.RadianValue, !checkBoxFix3rd.Checked));
            }

            var angles = Euler.DecomposeMatrix2(rot * RotBase.Inverse(), settings.ToArray());

            skip = true;
            numericBoxExp1.RadianValue = angles[0];
            if (checkBoxEnable2nd.Checked)
            {
                numericBoxExp2.RadianValue = angles[1];
            }
            if (checkBoxEnable3rd.Checked)
            {
                numericBoxExp3.RadianValue = angles[2];
            }
            skip = false;
            NumericBoxExp_ValueChanged(new object(), new EventArgs());
        }
 public void Contain(Vector3 boxA, Vector3 boxB, Euler euler, float volume)
 {
     if (!this.setted || this.volume > volume)
     {
         Set(boxA, boxB, euler, volume);
     }
 }
Ejemplo n.º 3
0
        protected void TestReasoner(DalcRdfStore dalcStore)
        {
            var   store  = new Store(dalcStore);
            Euler engine = new Euler(new N3Reader(new StringReader(eulerRules)));

            store.AddReasoner(engine);

            Console.WriteLine(
                "Is Adam a parent of Bill? " +
                store.Contains(
                    new Statement(baseNs + "persons#1", baseNs + "terms#is_parent", (Entity)(baseNs + "persons#4"))).ToString());
            Console.WriteLine(
                "Is Eve a parent of Bill? " +
                store.Contains(
                    new Statement(baseNs + "persons#2", baseNs + "terms#is_parent", (Entity)(baseNs + "persons#4"))).ToString());

            Console.Write("Children of Eve: ");
            var res = store.Select(new Statement(null, baseNs + "terms#is_child", (Entity)(baseNs + "persons#2")));

            foreach (var st in res)
            {
                var nameRes = store.Select(new Statement(st.Subject.Uri, ns_foaf_name, null));
                Console.Write(String.Format("({0})", dalcStore.GetDataKey(st.Subject).Id));
                foreach (var nameSt in nameRes)
                {
                    Console.Write(nameSt.Object.ToString() + " ");
                }
            }
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            try
            {
                Console.Write("Input n = ");
                n = Double.Parse(Console.ReadLine());
                Console.Write("Input k = ");
                k = Double.Parse(Console.ReadLine());
            }
            catch
            {
                Console.WriteLine("Input Error. Using values: n = {0}, k = {1}", n, k);
            }
            method = new Euler(n, k);

            Console.WriteLine("Forecast:");
            foreach (var value in method.Forecast())
            {
                Console.WriteLine(value.x.ToString() + "\t " + Math.Round(value.y, 4));
            }
            Console.WriteLine("Correction:");
            foreach (var value in method.Correction())
            {
                Console.WriteLine(value.x.ToString() + "\t " + Math.Round(value.y, 4));
            }
            Console.ReadKey();
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Rotates specified vector by specified orientation
        /// </summary>
        /// <param name="orientation">
        ///     given orientation
        /// </param>
        /// <param name="vector">
        ///     given float vector
        /// </param>
        /// <returns>
        ///     rotated float vector
        /// </returns>
        public static FVector Rotate(Euler orientation, FVector vector)
        {
            var headingRadians = orientation.Heading * _piTimes2;
            var pitchRadians   = orientation.Pitch * _piTimes2;
            var rollRadians    = orientation.Roll * _piTimes2;

            var cosHeading = Math.Cos(headingRadians);
            var sinHeading = Math.Sin(headingRadians);
            var cosPitch   = Math.Cos(pitchRadians);
            var sinPitch   = Math.Sin(pitchRadians);
            var cosRoll    = Math.Cos(rollRadians);
            var sinRoll    = Math.Sin(rollRadians);

            // Roll around Z axis
            var postRollX = vector.X * cosRoll - vector.Y * sinRoll;
            var postRollY = vector.X * sinRoll + vector.Y * cosRoll;
            var postRollZ = vector.Z;

            // Pitch around X axis
            var postPitchX = postRollX;
            var postPitchY = postRollY * cosPitch - postRollZ * sinPitch;
            var postPitchZ = postRollY * sinPitch + postRollZ * cosPitch;

            // heading around y axis

            return(new FVector {
                X = (float)(postPitchX * cosHeading + postPitchZ * sinHeading),
                Y = (float)postPitchY,
                Z = (float)(-postPitchX * sinHeading + postPitchZ * cosHeading)
            });
        }
Ejemplo n.º 6
0
        public void Update()
        {
            PositionApproximation.Run(PositionApproximation.Output);

            for (int i = 0; i < Atoms.Count; i++)
            {
                Atom atom = Atoms[i];

                Vector2 p0 = this.PositionApproximation.Output;
                Vector2 p1 = atom.PositionApproximation.Output;

                if (Intersects(atom))
                {
                    if (!Name.Equals("Proton") && !Name.Equals("Neutrone"))
                    {
                        VelocityApproximation = new Euler(new Vector2(), DELTA0)
                        {
                            f = VelocityApproximation.f
                        }
                    }
                    ;

                    Vector2 n = p1 - p0;
                    double  l = n.Length();
                    n /= l;

                    double overlapped = this.Radius + atom.Radius - l;
                    this.PositionApproximation.Output += n * overlapped;
                }
            }
        }
Ejemplo n.º 7
0
 public CompiledMeshNode(CompiledModel Mesh, Texture2D Texture, Euler Orientation = null)
 {
     this.Mesh = Mesh;
     this.Texture = Texture;
     this.Orientation = Orientation;
     if (this.Orientation == null) this.Orientation = new Euler();
 }
Ejemplo n.º 8
0
        public void MergeFrom(Pose3D other)
        {
            if (other == null)
            {
                return;
            }
            if (other.position_ != null)
            {
                if (position_ == null)
                {
                    Position = new global::Ubii.DataStructure.Vector3();
                }
                Position.MergeFrom(other.Position);
            }
            switch (other.OrientationCase)
            {
            case OrientationOneofCase.Quaternion:
                if (Quaternion == null)
                {
                    Quaternion = new global::Ubii.DataStructure.Quaternion();
                }
                Quaternion.MergeFrom(other.Quaternion);
                break;

            case OrientationOneofCase.Euler:
                if (Euler == null)
                {
                    Euler = new global::Ubii.DataStructure.Vector3();
                }
                Euler.MergeFrom(other.Euler);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Ejemplo n.º 9
0
        public Frame Create(string name = null,
                            IGraphicsProvider component          = null,
                            Vector3 localPosition                = default(Vector3),
                            Euler localRotationEuler             = default(Euler),
                            Vector3 localScale                   = default(Vector3),
                            Action <Frame, float> updateCallback = null)
        {
            if (name == null)
            {
                if (component != null && component is INameable)
                {
                    name = ((INameable)component).Name;
                }
                else
                {
                    name = "Node" + _nodes.Count;
                }
            }

            var node = new Frame(name, component);

            node.LocalPosition = localPosition;
            node.LocalEuler    = localRotationEuler;
            node.LocalScale    = localScale == default(Vector3) ? Vector3.One : localScale;
            node.ComputeLocalPose();
            node.CommitChanges();
            _nodes.Add(node);
            if (updateCallback != null)
            {
                _dynamics.Add(new Dynamic(x => updateCallback(node, x)));
            }
            node.OnSceneAttach(this);
            return(node);
        }
Ejemplo n.º 10
0
        private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = (int)((DataRowView)bindingSource2.Current).Row[0];

            if (zoneAxes[i].IsTwoPhoho)
            {
                for (int j = 0; j < formTEMID.formMain.listBox.Items.Count; j++)
                {
                    if ((Crystal)formTEMID.formMain.listBox.Items[j] == zoneAxis[i].Phase)
                    {
                        formTEMID.formMain.listBox.SelectionMode = SelectionMode.One;
                        formTEMID.formMain.listBox.SelectedIndex = j;
                        formTEMID.formMain.listBox.SelectionMode = SelectionMode.MultiExtended;
                        break;
                    }
                }
                formTEMID.formMain.SetRotation(Euler.SerchEulerAngleFromZoneAxes(zoneAxes[i].Za1, zoneAxes[i].Za2, formTEMID.formMain.Crystal));
            }
            else
            {
                for (int j = 0; j < formTEMID.formMain.listBox.Items.Count; j++)
                {
                    if ((Crystal)formTEMID.formMain.listBox.Items[j] == zoneAxis[i].Phase)
                    {
                        formTEMID.formMain.listBox.SelectionMode = SelectionMode.One;
                        formTEMID.formMain.listBox.SelectedIndex = j;
                        formTEMID.formMain.listBox.SelectionMode = SelectionMode.MultiExtended;
                        break;
                    }
                }
                formTEMID.formMain.SetRotation(Euler.SerchEulerAngleFromZoneAxes(zoneAxes[i].Za1, zoneAxes[i].Za2, zoneAxes[i].Za3, formTEMID.formMain.Crystal));
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Find the Euler matrix from the output of SolvePnP.
        /// </summary>
        /// <param name="rotation">The rotation matrix returned by SolvePnp.</param>
        /// <returns>The Euler matrix containing pitch, roll, and yaw angles.</returns>
        public static MatOfDouble GetEulerMatrix(Mat rotation)
        {
            // convert the 1x3 rotation vector to a full 3x3 matrix
            var r = new MatOfDouble(3, 3);

            Cv2.Rodrigues(rotation, r);

            // set up some shortcuts to rotation matrix
            double m00 = r.At <double>(0, 0);
            double m01 = r.At <double>(0, 1);
            double m02 = r.At <double>(0, 2);
            double m10 = r.At <double>(1, 0);
            double m11 = r.At <double>(1, 1);
            double m12 = r.At <double>(1, 2);
            double m20 = r.At <double>(2, 0);
            double m21 = r.At <double>(2, 1);
            double m22 = r.At <double>(2, 2);

            // set up output variables
            Euler euler_out  = new Euler();
            Euler euler_out2 = new Euler();

            if (Math.Abs(m20) >= 1)
            {
                euler_out.yaw  = 0;
                euler_out2.yaw = 0;

                // From difference of angles formula
                if (m20 < 0)  //gimbal locked down
                {
                    double delta = Math.Atan2(m01, m02);
                    euler_out.pitch  = Math.PI / 2f;
                    euler_out2.pitch = Math.PI / 2f;
                    euler_out.roll   = delta;
                    euler_out2.roll  = delta;
                }
                else // gimbal locked up
                {
                    double delta = Math.Atan2(-m01, -m02);
                    euler_out.pitch  = -Math.PI / 2f;
                    euler_out2.pitch = -Math.PI / 2f;
                    euler_out.roll   = delta;
                    euler_out2.roll  = delta;
                }
            }
            else
            {
                euler_out.pitch  = -Math.Asin(m20);
                euler_out2.pitch = Math.PI - euler_out.pitch;

                euler_out.roll  = Math.Atan2(m21 / Math.Cos(euler_out.pitch), m22 / Math.Cos(euler_out.pitch));
                euler_out2.roll = Math.Atan2(m21 / Math.Cos(euler_out2.pitch), m22 / Math.Cos(euler_out2.pitch));

                euler_out.yaw  = Math.Atan2(m10 / Math.Cos(euler_out.pitch), m00 / Math.Cos(euler_out.pitch));
                euler_out2.yaw = Math.Atan2(m10 / Math.Cos(euler_out2.pitch), m00 / Math.Cos(euler_out2.pitch));
            }

            // return result
            return(new MatOfDouble(1, 3, new double[] { euler_out.yaw, euler_out.roll, euler_out.pitch }));
        }
        public void IsPrimeTest()
        {
            // expected
            var primesBelow100 = new List <int>
            {
                2,
                3,
                5,
                7,
                11,
                13,
                17,
                19,
                23,
                29,
                31,
                37,
                41,
                43,
                47,
                53,
                59,
                61,
                67,
                71,
                73,
                79,
                83,
                89,
                97,
            };
            var got = (from n in Py.RangeExcl(-10, 100) where Euler.IsPrime(n) select n).ToList();

            Assert.Equal(primesBelow100, got);
        }
Ejemplo n.º 13
0
        public static Camera FromOrientation(string name, Vector3 position = default(Vector3), Euler orientation = default(Euler), float zn = 1f, float zf = 1000f)
        {
            Vector3 front, up, right;

            Euler.GetFrame(orientation, out right, out up, out front);
            return(new Camera(name, position, right, up, front, zn, zf));
        }
Ejemplo n.º 14
0
        private void BackgroundWorker()
        {
            running = true;
            OnStarted(this, new EventArgs());

            while (running)
            {
                if (!(Api.WaitNextFrame()))
                {
                    Thread.Sleep(10);
                }

                var frame          = new Frame();
                var euler          = new Euler();
                var cinemizerRot   = new Quat();
                var cinemizerEuler = new Euler();

                if (Api.GetFrame(ref frame))
                {
                    Api.QuatGetEuler(ref euler, frame.Rot);
                    Api.RotateTrackerToCinemizer(ref cinemizerRot, frame.Rot);
                    Api.QuatGetEuler(ref cinemizerEuler, cinemizerRot);

                    Euler = cinemizerEuler;

                    newData = true;
                }
            }
        }
Ejemplo n.º 15
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc =
                (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc == null)
            {
                return(value);
            }
            pd        = context.PropertyDescriptor;
            component = context.Instance;

            if (pd == null)
            {
                return(value);
            }

            Vector3 v = (Vector3)value;

            using (EulerEditor ctrol = new EulerEditor(Euler.FromDirection(v)))
            {
                ctrol.EulerChanged += ctrol_EulerChanged;
                edSvc.DropDownControl(ctrol);
                return(ctrol.Orientation.ToDirection());
            }
        }
Ejemplo n.º 16
0
 public MeshNode(Mesh Mesh, Texture2D Texture, Euler Orientation = null)
 {
     this.Mesh = Mesh;
     this.Texture = Texture;
     this.Orientation = Orientation;
     if (this.Orientation == null) this.Orientation = new Euler();
 }
Ejemplo n.º 17
0
        public void GraphV2WithCycleShouldReturnRightEulerCycle()
        {
            var euler = new Euler(new Graph(_dirPath + "v2GraphWithCycle.json"));
            var cycle = euler.FindEulerCycle(0);

            cycle.Should().BeEquivalentTo(new Queue <int>(new[] { 0, 1, 2, 3, 4, 0 }));
            PrintCycle(cycle);
        }
Ejemplo n.º 18
0
 public void Set(Vector3 boxA, Vector3 boxB, Euler euler, float volume)
 {
     this.boxA   = boxA;
     this.boxB   = boxB;
     this.euler  = euler;
     this.volume = volume;
     this.setted = true;
 }
Ejemplo n.º 19
0
 private void tbOk_Click(object sender, EventArgs e)
 {
     DialogResult        = System.Windows.Forms.DialogResult.OK;
     orientation.Heading = Euler.ToRadians((float)acHeading.Angle);
     orientation.Pitch   = Euler.ToRadians((float)acPitch.Angle);
     orientation.Roll    = Euler.ToRadians((float)acRoll.Angle);
     Close();
 }
Ejemplo n.º 20
0
        private float GetPitchDelta(float dt)
        {
            var remaining = Euler.Diff(TotalPitch, TargetPitch);
            var sign      = Math.Sign(remaining);
            var delta     = Math.Min(AimingSpeed * dt, Mathf.Abs(remaining));

            return((Pitch + delta * sign).Clamp360());
        }
Ejemplo n.º 21
0
        public void EulerTestSmallest_EvenlyDivisible_ByNumber_From_1to11()
        {
            var euler = new Euler();

            var result = euler.SmallestMultiple(11, 11);

            Assert.AreEqual(27720, result);
        }
Ejemplo n.º 22
0
        public void EulerTestSmallest_EvenlyDivisible_ByNumber_From_1to20()
        {
            var euler = new Euler();

            var result = euler.SmallestMultiple(20, 20);

            Assert.AreEqual(232792560, result);
        }
Ejemplo n.º 23
0
 public void Set(ref MinBounding minBounding)
 {
     this.boxA   = minBounding.boxA;
     this.boxB   = minBounding.boxB;
     this.euler  = minBounding.euler;
     this.volume = minBounding.volume;
     this.setted = minBounding.setted;
 }
Ejemplo n.º 24
0
        public EulerEditor(Euler euler)
        {
            InitializeComponent();

            angleControl1.Angle = euler.HeadingAngle;
            angleControl2.Angle = euler.PitchAngle;
            angleControl3.Angle = euler.RollAngle;
        }
Ejemplo n.º 25
0
    private void OrientationInterface_StateChanged(object sender, TimeValue timestamp, int sensor, Quaternion report)
    {
        Euler euler = quatToEuler(report);

        data[0] = euler.yaw;
        data[1] = euler.roll;  // should be pitch, but for reasons I don't understand roll an pitch are mixed up
        data[2] = euler.pitch; //should be roll
    }
Ejemplo n.º 26
0
        /// <summary>
        /// 角度をセット.
        /// </summary>
        /// <param name="fromExp">trueの時は、Experimental coordinatesの制限を解除して、オイラー角を更新する。</param>
        public void SetRotation(bool renewExpEuler = true)
        {
            if (skip)
            {
                return;
            }

            numericBoxPhi.RadianValue   = FormMain.Phi;
            numericBoxTheta.RadianValue = FormMain.Theta;
            numericBoxPsi.RadianValue   = FormMain.Psi;

            var rotMatrix = Euler.SetEulerAngle(numericBoxPhi.RadianValue, numericBoxTheta.RadianValue, numericBoxPsi.RadianValue);

            skip = true;
            numericBox11.Value = RotReciPro.E11;
            numericBox12.Value = RotReciPro.E12;
            numericBox13.Value = RotReciPro.E13;
            numericBox21.Value = RotReciPro.E21;
            numericBox22.Value = RotReciPro.E22;
            numericBox23.Value = RotReciPro.E23;
            numericBox31.Value = RotReciPro.E31;
            numericBox32.Value = RotReciPro.E32;
            numericBox33.Value = RotReciPro.E33;
            skip = false;

            if (renewExpEuler && Linked)
            {
                skip = true;
                checkBoxEnable2nd.Checked = checkBoxEnable3rd.Checked = true;
                checkBoxFix1st.Checked    = checkBoxFix2nd.Checked = checkBoxFix3rd.Checked = false;
                var settings = new List <(V3 Vec, double Angle, bool Variable)>();
                var dir      = getExpDirections();
                settings.Add((dir[0], numericBoxExp1.RadianValue, !checkBoxFix1st.Checked));
                settings.Add((dir[1], numericBoxExp2.RadianValue, !checkBoxFix2nd.Checked));
                settings.Add((dir[2], numericBoxExp3.RadianValue, !checkBoxFix3rd.Checked));

                var angles = Euler.DecomposeMatrix2(RotReciPro * RotBase.Inverse(), settings.ToArray());
                numericBoxExp1.RadianValue = angles[0];
                numericBoxExp2.RadianValue = angles[1];
                numericBoxExp3.RadianValue = angles[2];
                skip = false;
            }
            //ReciPro coordinatesの描画
            var dirReciPro   = new[] { new V3(0, 0, 1), new V3(1, 0, 0), new V3(0, 0, 1) };
            var angleReciPro = new[] { FormMain.Phi, FormMain.Theta, FormMain.Psi };

            setGonio(glControlReciProGonio, dirReciPro, angleReciPro);
            setObject(glControlReciProObjects, dirReciPro, angleReciPro);
            setAxes(glControlReciProAxes);

            //Experimetal coordinatesの描画
            var dirExp   = getExpDirections();
            var angleExp = new[] { numericBoxExp1.RadianValue, numericBoxExp2.RadianValue, numericBoxExp3.RadianValue };

            setGonio(glControlExpGonio, dirExp, angleExp);
            setObject(glControlExpObjects, dirExp, angleExp);
            setAxes(glControlExpAxes);
        }
Ejemplo n.º 27
0
 public SceneNode(Renderable Renderable, Euler Euler = null)
 {
     this.Orientation = Euler;
     if (this.Orientation == null)
     {
         this.Orientation = new Euler();
     }
     this.Renderable = Renderable;
 }
Ejemplo n.º 28
0
 private void angleControl3_AngleChanged(object sender, EventArgs e)
 {
     if (EulerChanged != null)
     {
         EulerChanged(this, new Euler(Euler.ToRadians((float)angleControl1.Angle),
                                      Euler.ToRadians((float)angleControl2.Angle),
                                      Euler.ToRadians((float)angleControl3.Angle)));
     }
 }
Ejemplo n.º 29
0
    public static void Main()
    {
        Euler euler = new Euler();
        // 解を計算(初期値, 収束条件)
        double xn = euler.calc(0, 0, 1, 100);

        // 結果表示
        System.Console.WriteLine(xn); // x(1)=9.99973438601112
    }
Ejemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        deltatime   += Time.deltaTime;
        arPanelAngle = arPanel.transform.localEulerAngles;

        /*
         * if (deltatime > 1.0f) {
         *  //StartCoroutine (GetSensorData ());
         *  setTarget (axisdata);
         *
         *  deltatime -= 1.0f;
         * }
         */
        if (isCalibrate)
        {
            //キャリブレーション中 3秒
            if (deltatime > 3.0f)
            {
                //終了
                CaliburationEnd();
            }
        }
        if (eulerdata != null)
        {
            SetTargetEuler(eulerdata);
        }

        //MqttTest();
        mqttController.OnMessageReceived.Subscribe(message => {
            //データ成型
            string json      = "";
            string[] arr     = message.Split('{');
            json             = string.Join("{\"", arr);
            string[] semiArr = json.Split(':');
            json             = string.Join("\":", semiArr);
            string[] comArr  = json.Split(',');
            json             = string.Join(",\"", comArr);
            NineAxis list    = JsonUtility.FromJson <NineAxis> (json);
            axisdata         = list;
        });
        mqttEuler.OnMessageReceived.Subscribe(message => {
            //データ成型
            string json      = "";
            string[] arr     = message.Split('{');
            json             = string.Join("{\"", arr);
            string[] semiArr = json.Split(':');
            json             = string.Join("\":", semiArr);
            string[] comArr  = json.Split(',');
            json             = string.Join(",\"", comArr);
            Euler data       = JsonUtility.FromJson <Euler> (json);
            eulerdata        = data;
            if (isCalibrate)
            {
                calEulerList.Add(data);
            }
        });
    }
Ejemplo n.º 31
0
 public SpriteNode(Mesh mesh, Euler Orientation = null)
 {
     this.Mesh        = mesh;
     this.Orientation = Orientation;
     if (this.Orientation == null)
     {
         this.Orientation = new Euler();
     }
 }
Ejemplo n.º 32
0
    void SetTargetEuler(Euler euler)
    {
        float targetPitch = euler.pitch - calibrateEuler.pitch + arPanelAngle.x + 90.0f;
        float targetHead  = euler.head - calibrateEuler.head + arPanelAngle.y;
        float targetRoll  = euler.roll - calibrateEuler.roll;

        target.transform.rotation = Quaternion.Euler(
            targetPitch,
            targetHead,
            targetRoll);
        target2.transform.rotation = Quaternion.Euler(
            targetPitch,
            targetHead,
            targetRoll);
        if (targetStateNum == 0)
        {
            //平常時
            if (targetPitch < -30.0f)
            {
                warningText.text = "Warning!\n危険な体勢です!";
                spotLight.SetActive(true);
            }
            else
            {
                warningText.text = "";
                spotLight.SetActive(false);
            }
        }
        //睡眠時
        else if (targetStateNum == 1)
        {
            if (targetPitch < -30.0f)
            {
                warningText.text = "Warning!\n危険な体勢です!";
                spotLight.SetActive(true);
            }
            else
            {
                warningText.text = "";
                spotLight.SetActive(false);
            }
        }
        else if (targetStateNum == 2)
        {
            //食事
            if (targetPitch < -30.0f || targetPitch > 30.0f || targetRoll < -45.0f || targetRoll > 45.0f)
            {
                warningText.text = "Warning!\n危険な体勢です!";
                spotLight.SetActive(true);
            }
            else
            {
                warningText.text = "";
                spotLight.SetActive(false);
            }
        }
    }
Ejemplo n.º 33
0
        public ActionResult Index(string  req = "xx")
        {
            decimal resultado = 0;
            Euler euler = new Euler();

            if (req!=null &&
                req.Length>0)
            {
                resultado = euler.Solve();
            }

            ViewBag.Message = "Resolução do Euler!";
            ViewBag.Resultado = resultado;
            return View();
        }
Ejemplo n.º 34
0
    public static void Main(string[] args)
    {
        if (args.Length < 2) {
            Console.WriteLine("Usage: euler.exe axioms.n3 axioms... {questions.n3 | -sparql query.sparql}");
            return;
        }

        // Load Axioms

        bool sparql = false;

        MemoryStore axioms = new MemoryStore();
        for (int i = 0; i < args.Length-1; i++) {
            if (i > 0 && i == args.Length-2 && args[i] == "-sparql") {
                sparql = true;
                break;
            }

            N3Reader axiomsreader = new N3Reader(args[i]);
            axiomsreader.BaseUri = "http://www.example.org/arbitrary/base#";
            axioms.Import(axiomsreader);
        }

        Euler engine = new Euler(axioms);

        // Load question
        if (!sparql) {
            MemoryStore question = new MemoryStore();
            question.Import(new N3Reader(args[args.Length-1]));

            Proof[] proofs = engine.Prove(null, question.ToArray());

            foreach (Proof p in proofs) {
                Console.WriteLine(p.ToString());
            }
        } else {
            using (StreamReader fs = new StreamReader(args[args.Length-1])) {
                string q = fs.ReadToEnd();

                Store store = new Store();
                store.AddReasoner(engine);

                SparqlEngine s = new SparqlEngine(q);
                s.Run(store, Console.Out);
            }
        }
    }
Ejemplo n.º 35
0
    protected override void OnLoad(EventArgs e)
    {
        RdfStore = new MemoryStore();
        RdfStore.Import(
            new RdfXmlReader(@"c:\temp\_1.rdf"));

        string depRules = @"
        @prefix n: <urn:schemas-nreco:metadata:terms#>.
        @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
        @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.

        { ?a n:dependentFrom ?b . ?b n:dependentFrom ?c .} => {?a n:dependentFrom ?c}.
        { ?a n:dependentFrom ?b } => { ?b n:usedBy ?a}.
        { ?a n:usedBy ?b . ?b n:usedBy ?c .} => {?a n:usedBy ?c}.
        ";

        Euler engine = new Euler(new N3Reader(new StringReader(depRules)));

        RdfStore.AddReasoner(new RDFS(RdfStore));
        RdfStore.AddReasoner(engine);

        string rdfQuery = @"
        @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
        @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
        @prefix p: <urn:schemas-nreco:metadata:dotnet:property#>.
        @prefix t: <urn:schemas-nreco:metadata:dotnet:type#>.
        @prefix w: <file:///d:/Vitalik/GoogleCode/NReco/examples/NReco.Examples.WebApp/web/#>.
        @prefix cso: <http://cos.ontoware.org/cso#>.
        @prefix n: <urn:schemas-nreco:metadata:terms#>.
        w:db n:usedBy ?t2.
        ";

        Query query = new GraphMatch(new N3Reader(new StringReader(rdfQuery)));
        StringWriter wr = new StringWriter();
        QueryResultSink sink = new SparqlXmlQuerySink(wr);
        query.Run(RdfStore, sink);
        Result = wr.ToString();

        base.OnLoad(e);
    }
Ejemplo n.º 36
0
 //public static double FourBytes(int a1, int a2, int a3, int a4)
 //{
 //    double a;
 //    a = a1 * System.Math.Pow((double)2, 24) + a2 * System.Math.Pow((double)2, 16) + a3 * System.Math.Pow((double)2, 8) + a4;
 //    if (a > 2147483648)
 //    {
 //        a -= 4294967296;
 //    }
 //    return a;
 //}
 //public static CQuaternion getRawQuat(int[] raw, int count)//count =23;//一个节点一次的数据是23 包含id 回车换行等等信息。
 //{
 //    double q0, q1, q2, q3, mag;
 //    q0 = FourBytes(raw[3], raw[4], raw[5], raw[6]) / System.Math.Pow((double)2, 30);
 //    q1 = FourBytes(raw[7], raw[8], raw[9], raw[10]) / System.Math.Pow((double)2, 30);
 //    q2 = FourBytes(raw[11], raw[12], raw[13], raw[14]) / System.Math.Pow((double)2, 30);
 //    q3 = FourBytes(raw[15], raw[16], raw[17], raw[18]) / System.Math.Pow((double)2, 30);
 //    mag = System.Math.Sqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3);
 //    CQuaternion result = new CQuaternion(q0 / mag, q1 / mag, q2 / mag, q3 / mag);
 //    return result;
 //}
 public static Euler Quat2angle(double q_0, double q_1, double q_2, double q_3, int type)
 {
     double r11 = 0;
     double r12 = 0;
     double r21 = 0;
     double r31 = 0;
     double r32 = 0;
     Euler result = new Euler();
     switch (type)
     {
         case 1:			//'zyx
             r11 = 2 * (q_1 * q_2 + q_0 * q_3);
             r12 = System.Math.Pow(q_0, 2) + System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             r21 = -2 * (q_1 * q_3 - q_0 * q_2);
             r31 = 2 * (q_2 * q_3 + q_0 * q_1);
             r32 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) + System.Math.Pow(q_3, 2);
             break;
         case 2:			//'zxy'
             r11 = -2 * (q_1 * q_2 - q_0 * q_3);
             r12 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) + System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             r21 = 2 * (q_2 * q_3 + q_0 * q_1);
             r31 = -2 * (q_1 * q_3 - q_0 * q_2);
             r32 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) + System.Math.Pow(q_3, 2);
             break;
         case 3:			//'yxz'
             r11 = 2 * (q_1 * q_3 + q_0 * q_2);
             r12 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) + System.Math.Pow(q_3, 2);
             r21 = -2 * (q_2 * q_3 - q_0 * q_1);
             r31 = 2 * (q_1 * q_2 + q_0 * q_3);
             r32 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) + System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             break;
         case 4:			 //'yzx'
             r11 = -2 * (q_1 * q_3 - q_0 * q_2);
             r12 = System.Math.Pow(q_0, 2) + System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             r21 = 2 * (q_1 * q_2 + q_0 * q_3);
             r31 = -2 * (q_2 * q_3 - q_0 * q_1);
             r32 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) + System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             break;
         case 5:			//'xyz'
             r11 = -2 * (q_2 * q_3 - q_0 * q_1);
             r12 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) + System.Math.Pow(q_3, 2);
             r21 = 2 * (q_1 * q_3 + q_0 * q_2);
             r31 = -2 * (q_1 * q_2 - q_0 * q_3);
             r32 = System.Math.Pow(q_0, 2) + System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             break;
         case 6: //'xzy'
             r11 = 2 * (q_2 * q_3 + q_0 * q_1);
             r12 = System.Math.Pow(q_0, 2) - System.Math.Pow(q_1, 2) + System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             r21 = -2 * (q_1 * q_2 - q_0 * q_3);
             r31 = 2 * (q_1 * q_3 + q_0 * q_2);
             r32 = System.Math.Pow(q_0, 2) + System.Math.Pow(q_1, 2) - System.Math.Pow(q_2, 2) - System.Math.Pow(q_3, 2);
             break;
     }
     result.Eul_1 = System.Math.Atan2(r11, r12);
     result.Eul_2 = System.Math.Asin(r21);
     result.Eul_3 = System.Math.Atan2(r31, r32);
     return result;
 }
Ejemplo n.º 37
0
 public BranchNode(Euler Orientation = null)
 {
     this.Orientation = Orientation;
     if (this.Orientation == null) this.Orientation = new Euler();
 }
Ejemplo n.º 38
0
    public static void Main()
    {
        // Create the instance data

        MemoryStore dataModel = new MemoryStore();

        BNode paris = new BNode("paris");
        BNode orleans = new BNode("orleans");
        BNode chartres = new BNode("chartres");
        BNode amiens = new BNode("amiens");
        BNode blois = new BNode("blois");
        BNode bourges = new BNode("bourges");
        BNode tours = new BNode("tours");
        BNode lemans = new BNode("lemans");
        BNode angers = new BNode("angers");
        BNode nantes = new BNode("nantes");

        Entity oneway = new Entity("http://www.agfa.com/w3c/euler/graph.axiom#oneway");
        Entity path = new Entity("http://www.agfa.com/w3c/euler/graph.axiom#path");

        dataModel.Add(new Statement(paris, oneway, orleans));
        dataModel.Add(new Statement(paris, oneway, chartres));
        dataModel.Add(new Statement(paris, oneway, amiens));
        dataModel.Add(new Statement(orleans, oneway, blois));
        dataModel.Add(new Statement(orleans, oneway, bourges));
        dataModel.Add(new Statement(blois, oneway, tours));
        dataModel.Add(new Statement(chartres, oneway, lemans));
        dataModel.Add(new Statement(lemans, oneway, angers));
        dataModel.Add(new Statement(lemans, oneway, tours));
        dataModel.Add(new Statement(angers, oneway, nantes));

        // Create the inference rules by reading them from a N3 string.

        string rules =
            "@prefix : <http://www.agfa.com/w3c/euler/graph.axiom#>.\n" +
            "\n" +
            "{ ?a :oneway ?b } => { ?a :path ?b } .\n" +
            "{ ?a :path ?b . ?b :path ?c . } => { ?a :path ?c } .\n";

        // Create our question in the form of a statement to test.

        Statement question = new Statement(paris, path, nantes);

        // Create the Euler engine

        Euler engine = new Euler(new N3Reader(new StringReader(rules)));

        // First Method of Inference:
        // Ask the engine whether there is a path from paris to nantes.
        // The Prove method will return a list of proofs, or an empty
        // array if it could not find a proof.

        foreach (Proof p in engine.Prove(dataModel, new Statement[] { question })) {
            Console.WriteLine(p.ToString());
        }

        // Second Method of Inference:
        // Apply the engine to the data model and then use the data
        // model's Contains method to see if the statement is "in"
        // the model + reasoning.

        dataModel.AddReasoner(engine);

        Console.WriteLine("Euler Says the Question is: " + dataModel.Contains(question));
    }
Ejemplo n.º 39
0
		/*@brief Get the matrix represented as euler angles around ZYX
		 @param yaw Yaw around X axis
		 @param pitch Pitch around Y axis
		 @param roll around X axis 
		 @param solution_number Which solution of two possible solutions ( 1 or 2) are possible values*/
		public void getEulerZYX( out float yaw, out float pitch, out float roll, int solution_number = 1 )
		{

			Euler euler_out = new Euler();
			Euler euler_out2 = new Euler(); //second solution
											//get the pointer to the raw data

			// Check that pitch is not at a singularity
			if( btScalar.btFabs( m_el2.x ) >= 1 )
			{
				euler_out.yaw = 0;
				euler_out2.yaw = 0;

				// From difference of angles formula
				float delta = btScalar.btAtan2( m_el0.x, m_el0.z );
				if( m_el2.x > 0 )  //gimbal locked up
				{
					euler_out.pitch = btScalar.SIMD_HALF_PI;
					euler_out2.pitch = btScalar.SIMD_HALF_PI;
					euler_out.roll = euler_out.pitch + delta;
					euler_out2.roll = euler_out.pitch + delta;
				}
				else // gimbal locked down
				{
					euler_out.pitch = -btScalar.SIMD_HALF_PI;
					euler_out2.pitch = -btScalar.SIMD_HALF_PI;
					euler_out.roll = -euler_out.pitch + delta;
					euler_out2.roll = -euler_out.pitch + delta;
				}
			}
			else
			{
				euler_out.pitch = -btScalar.btAsin( m_el2.x );
				euler_out2.pitch = btScalar.SIMD_PI - euler_out.pitch;

				euler_out.roll = btScalar.btAtan2( m_el2.y / btScalar.btCos( euler_out.pitch ),
					m_el2.z / btScalar.btCos( euler_out.pitch ) );
				euler_out2.roll = btScalar.btAtan2( m_el2.y / btScalar.btCos( euler_out2.pitch ),
					m_el2.z / btScalar.btCos( euler_out2.pitch ) );

				euler_out.yaw = btScalar.btAtan2( m_el1.x / btScalar.btCos( euler_out.pitch ),
					m_el0.x / btScalar.btCos( euler_out.pitch ) );
				euler_out2.yaw = btScalar.btAtan2( m_el1.x / btScalar.btCos( euler_out2.pitch ),
					m_el0.x / btScalar.btCos( euler_out2.pitch ) );
			}

			if( solution_number == 1 )
			{
				yaw = euler_out.yaw;
				pitch = euler_out.pitch;
				roll = euler_out.roll;
			}
			else
			{
				yaw = euler_out2.yaw;
				pitch = euler_out2.pitch;
				roll = euler_out2.roll;
			}
		}
Ejemplo n.º 40
0
 public SceneNode(Renderable Renderable, Euler Euler = null)
 {
     this.Orientation = Euler;
     if (this.Orientation == null) this.Orientation = new Euler();
     this.Renderable = Renderable;
 }
Ejemplo n.º 41
0
	private static void EulerQuery (SelectableSource source, string rules, Statement[] queries)
	{
		Store store = new Store (source);

		Euler engine = new Euler(new N3Reader(new StringReader(rules)));

		foreach (Proof p in engine.Prove (store, queries)) {
			foreach (Statement s in p.Proved)
				Console.WriteLine(s);
		}
	}
        public virtual void LoadData(BZNReader reader)
        {
            IBZNToken tok;

            tok = reader.ReadToken();
            if (!tok.Validate("illumination", BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse illumination/FLOAT");
            illumination = tok.GetSingle();

            tok = reader.ReadToken();
            if (!tok.Validate("pos", BinaryFieldType.DATA_VEC3D)) throw new Exception("Failed to parse pos/VEC3D");
            pos = tok.GetVector3D();

            if (reader.BinaryMode)
            {
                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse euler's FLOAT");
                float euler_mass = tok.GetSingle();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse euler's FLOAT");
                float euler_mass_inv = tok.GetSingle();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse euler's FLOAT");
                float euler_v_mag = tok.GetSingle();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse euler's FLOAT");
                float euler_v_mag_inv = tok.GetSingle();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse euler's FLOAT");
                float euler_I = tok.GetSingle();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse euler's FLOAT");
                float euler_k_i = tok.GetSingle();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_VEC3D)) throw new Exception("Failed to parse euler's VEC3D");
                Vector3D euler_v = tok.GetVector3D();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_VEC3D)) throw new Exception("Failed to parse euler's VEC3D");
                Vector3D euler_omega = tok.GetVector3D();

                tok = reader.ReadToken();
                if (!tok.Validate(null, BinaryFieldType.DATA_VEC3D)) throw new Exception("Failed to parse euler's VEC3D");
                Vector3D euler_Accel = tok.GetVector3D();

                euler = new Euler()
                {
                    mass = euler_mass,
                    mass_inv = euler_mass_inv,
                    v_mag = euler_v_mag,
                    v_mag_inv = euler_v_mag_inv,
                    I = euler_I,
                    k_i = euler_k_i,
                    v = euler_v,
                    omega = euler_omega,
                    Accel = euler_Accel
                };
            }
            else
            {
                tok = reader.ReadToken();
                if (!tok.Validate("euler", BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse euler");
                euler = tok.GetEuler();
            }

            tok = reader.ReadToken();
            if (!tok.Validate("seqNo", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse seqNo/SHORT");
            //seqNo = tok.GetUInt16();
            seqNo = tok.GetUInt32();

            if (reader.N64)
            {
                tok = reader.ReadToken();
                if (!tok.Validate("name", BinaryFieldType.DATA_CHAR)) throw new Exception("Failed to parse name/CHAR");
                name = tok.GetString();
            }
            else
            {
                if (reader.Version > 1030)
                {
                    tok = reader.ReadToken();
                    if (!tok.Validate("name", BinaryFieldType.DATA_CHAR)) throw new Exception("Failed to parse name/CHAR");
                    name = tok.GetString();
                }
            }

            tok = reader.ReadToken();
            if (!tok.Validate("isObjective", BinaryFieldType.DATA_BOOL)) throw new Exception("Failed to parse isObjective/BOOL");
            isObjective = tok.GetBoolean();

            tok = reader.ReadToken();
            if (!tok.Validate("isSelected", BinaryFieldType.DATA_BOOL)) throw new Exception("Failed to parse isSelected/BOOL");
            isSelected = tok.GetBoolean();

            tok = reader.ReadToken();
            if (!tok.Validate("isVisible", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse isVisible/LONG");
            isVisible = tok.GetUInt32H();

            tok = reader.ReadToken();
            if (!tok.Validate("seen", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse seen/LONG");
            seen = tok.GetUInt32();

            if (reader.N64)
            {

            }
            else
            {
                //[10:03:38 PM] Kenneth Miller: I think I may have figured out what that stuff is, maybe
                //[10:03:50 PM] Kenneth Miller: They're timestamps
                //[10:04:04 PM] Kenneth Miller: playerShot, playerCollide, friendShot, friendCollide, enemyShot, groundCollide
                //[10:04:13 PM] Kenneth Miller: the default value is -HUGE_NUMBER (-1e30)
                //[10:04:26 PM] Kenneth Miller: And due to the nature of the game, groundCollide is the most likely to get set first
                //[10:05:02 PM] Kenneth Miller: Old versions of the mission format used to contain those values but later versions only include them in the savegame
                //[10:05:05 PM] Kenneth Miller: (not the mission)
                //[10:05:31 PM] Kenneth Miller: (version 1033 was where they were removed from the mission)
                if (reader.Version < 1033)
                {
                    tok = reader.ReadToken(); // float (-HUGE_NUMBER)
                    tok = reader.ReadToken(); // float (-HUGE_NUMBER)
                    tok = reader.ReadToken(); // float (-HUGE_NUMBER)
                    tok = reader.ReadToken(); // float (-HUGE_NUMBER)
                    tok = reader.ReadToken(); // float (-HUGE_NUMBER)
                    tok = reader.ReadToken(); // float
                }
            }

            tok = reader.ReadToken();
            if (!tok.Validate("healthRatio", BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse healthRatio/FLOAT");
            healthRatio = tok.GetSingle();

            tok = reader.ReadToken();
            if (!tok.Validate("curHealth", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse curHealth/LONG");
            curHealth = tok.GetUInt32();

            tok = reader.ReadToken();
            if (!tok.Validate("maxHealth", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse maxHealth/LONG");
            maxHealth = tok.GetUInt32();

            tok = reader.ReadToken();
            if (!tok.Validate("ammoRatio", BinaryFieldType.DATA_FLOAT)) throw new Exception("Failed to parse ammoRatio/FLOAT");
            ammoRatio = tok.GetSingle();

            tok = reader.ReadToken();
            if (!tok.Validate("curAmmo", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse curAmmo/LONG");
            curAmmo = tok.GetUInt32();

            tok = reader.ReadToken();
            if (!tok.Validate("maxAmmo", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse maxAmmo/LONG");
            maxAmmo = tok.GetUInt32();

            tok = reader.ReadToken();
            if (!tok.Validate("priority", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse priority/LONG");
            priority = tok.GetUInt32();

            tok = reader.ReadToken();
            if (!tok.Validate("what", BinaryFieldType.DATA_VOID)) throw new Exception("Failed to parse what/VOID");
            what = tok.GetUInt32H();

            tok = reader.ReadToken();
            if (!tok.Validate("who", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse who/LONG");
            who = tok.GetInt32();

            tok = reader.ReadToken();
            if (!tok.Validate("where", BinaryFieldType.DATA_PTR)) throw new Exception("Failed to parse where/PTR");
            where = tok.GetUInt32H();

            tok = reader.ReadToken();
            if (!tok.Validate("param", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse param/LONG");
            param = tok.GetUInt32();

            tok = reader.ReadToken();
            if (!tok.Validate("aiProcess", BinaryFieldType.DATA_BOOL)) throw new Exception("Failed to parse aiProcess/BOOL");
            aiProcess = tok.GetBoolean();

            tok = reader.ReadToken();
            if (!tok.Validate("isCargo", BinaryFieldType.DATA_BOOL)) throw new Exception("Failed to parse isCargo/BOOL");
            isCargo = tok.GetBoolean();

            tok = reader.ReadToken();
            if (!tok.Validate("independence", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse independence/LONG");
            independence = tok.GetUInt32();

            if (reader.N64)
            {
                tok = reader.ReadToken();
                UInt16 curPilotID = tok.GetUInt16();
                if (!BZNFile.BZn64IdMap.ContainsKey(curPilotID)) throw new InvalidCastException(string.Format("Cannot convert n64 curPilotID enumeration 0x(0:X2} to string curPilotID", curPilotID));
                curPilot = BZNFile.BZn64IdMap[curPilotID];
            }
            else
            {
                if (reader.Version > 1022)
                {
                    tok = reader.ReadToken();
                    if (!tok.Validate("curPilot", BinaryFieldType.DATA_ID)) throw new Exception("Failed to parse curPilot/ID");
                    curPilot = tok.GetString();
                }
                else
                {
                    tok = reader.ReadToken();
                    if (!tok.Validate("hasPilot", BinaryFieldType.DATA_BOOL)) throw new Exception("Failed to parse hasPilot/BOOL");
                    bool hasPilot = tok.GetBoolean();
                    curPilot = hasPilot ? isUser ? PrjID[0] + "suser" : PrjID[0] + "spilo" : string.Empty;
                }
            }

            if (reader.N64)
            {
                tok = reader.ReadToken();
                if (!tok.Validate("perceivedTeam", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse perceivedTeam/LONG");
                perceivedTeam = tok.GetInt32();
            }
            else
            {
                if (reader.Version > 1030)
                {
                    tok = reader.ReadToken();
                    if (!tok.Validate("perceivedTeam", BinaryFieldType.DATA_LONG)) throw new Exception("Failed to parse perceivedTeam/LONG");
                    perceivedTeam = tok.GetInt32();
                }
                else
                {
                    perceivedTeam = -1;
                }
            }
        }
Ejemplo n.º 43
0
        public static Matrix4 MakeRotationFromEuler(Euler euler)
        {
            var res = Matrix4.Identity;
            var te = res.elements;
            float x = euler.x, y = euler.y, z = euler.z;
            float a = Mathf.Cos(x), b = Mathf.Sin(x);
            float c = Mathf.Cos(y), d = Mathf.Sin(y);
            float e = Mathf.Cos(z), f = Mathf.Sin(z);

            if (euler.order == Euler.OrderMode.XYZ)
            {
                float ae = a * e, af = a * f, be = b * e, bf = b * f;

                te[0] = c * e;
                te[4] = -c * f;
                te[8] = d;

                te[1] = af + be * d;
                te[5] = ae - bf * d;
                te[9] = -b * c;

                te[2] = bf - ae * d;
                te[6] = be + af * d;
                te[10] = a * c;

            }
            else if (euler.order == Euler.OrderMode.YXZ)
            {
                float ce = c * e, cf = c * f, de = d * e, df = d * f;

                te[0] = ce + df * b;
                te[4] = de * b - cf;
                te[8] = a * d;

                te[1] = a * f;
                te[5] = a * e;
                te[9] = -b;

                te[2] = cf * b - de;
                te[6] = df + ce * b;
                te[10] = a * c;

            }
            else if (euler.order == Euler.OrderMode.ZXY)
            {
                float ce = c * e, cf = c * f, de = d * e, df = d * f;

                te[0] = ce - df * b;
                te[4] = -a * f;
                te[8] = de + cf * b;

                te[1] = cf + de * b;
                te[5] = a * e;
                te[9] = df - ce * b;

                te[2] = -a * d;
                te[6] = b;
                te[10] = a * c;
            }
            else if (euler.order == Euler.OrderMode.ZYX)
            {
                float ae = a * e, af = a * f, be = b * e, bf = b * f;

                te[0] = c * e;
                te[4] = be * d - af;
                te[8] = ae * d + bf;

                te[1] = c * f;
                te[5] = bf * d + ae;
                te[9] = af * d - be;

                te[2] = -d;
                te[6] = b * c;
                te[10] = a * c;

            }
            else if (euler.order == Euler.OrderMode.YZX)
            {
                float ac = a * c, ad = a * d, bc = b * c, bd = b * d;

                te[0] = c * e;
                te[4] = bd - ac * f;
                te[8] = bc * f + ad;

                te[1] = f;
                te[5] = a * e;
                te[9] = -b * e;

                te[2] = -d * e;
                te[6] = ad * f + bc;
                te[10] = ac - bd * f;
            }
            else if (euler.order == Euler.OrderMode.XZY)
            {
                float ac = a * c, ad = a * d, bc = b * c, bd = b * d;

                te[0] = c * e;
                te[4] = -f;
                te[8] = d * e;

                te[1] = ac * f + bd;
                te[5] = a * e;
                te[9] = ad * f - bc;

                te[2] = bc * f - ad;
                te[6] = b * e;
                te[10] = bd * f + ac;
            }

            // last column
            te[3] = 0;
            te[7] = 0;
            te[11] = 0;

            // bottom row
            te[12] = 0;
            te[13] = 0;
            te[14] = 0;
            te[15] = 1;

            return res;
        }
Ejemplo n.º 44
-1
        public Renderable(GraphicsDevice device, GuiDriver module, int width, int height, Euler Euler = null)
        {
            this.module = module;
            this.Orientation = Euler;
            if (this.Orientation == null) this.Orientation = new Euler();

            uiCamera = new Render.Cameras.OrthographicCamera(new Viewport(0, 0, width, height));
            uiRoot = new UIItem(new Rectangle(0, 0, width, height));
            uiRoot.settings = new PropertySet();

            uiCamera.focus = new Vector2(width / 2, height / 2);

            renderTarget = new RenderTarget2D(device, uiCamera.Viewport.Width, uiCamera.Viewport.Height);
            var rawGuiQuad = Geo.Gen.CreateQuad();
            rawGuiQuad = Geo.Gen.FacetCopy(rawGuiQuad);
            quadModel = Geo.CompiledModel.CompileModel(rawGuiQuad, device);
            uiRoot.defaults = module.defaultSettings;
        }