Example #1
0
 public T3(T4 t4, Scoped1 scoped1, Scoped3 scoped3, Single3 single3)
 {
     T4      = t4;
     Scoped1 = scoped1;
     Scoped3 = scoped3;
     Single3 = single3;
 }
Example #2
0
 protected override void ImageMouseDown(int x0, int y0, MouseButtons buttons)
 {
     base.ImageMouseDown(x0, y0, buttons);
     _mouseDownOrigin = Origin;
     _mouseDownRotMat = RotMat;
     _mouseDownInvMat = _mouseDownRotMat.Inverse();
 }
Example #3
0
        protected void PictureMoving(int x0, int y0, int dx, int dy)
        {
            float   zoom       = Zoom;
            Single3 moveVector = _mouseDownInvMat * (new Single3(-dx / zoom, 0, dy / zoom));

            Origin = _mouseDownOrigin + moveVector;
        }
Example #4
0
        private void DrawOrigin(Bitmap bufferBitmap)
        {
            Single3 origin    = Origin;
            PointF  p0        = Project(Single3.Zero);
            PointF  p1        = Project(new Single3(origin.X, 0, 0));
            PointF  p2        = Project(new Single3(origin.X, origin.Y, 0));
            PointF  originF   = Project(origin);
            float   pointSize = 8f;
            Font    font      = DefaultFont;

            using (Graphics graphics = Graphics.FromImage(bufferBitmap))
                using (SolidBrush brush = new SolidBrush(Color.LightGray))
                    using (Pen pen = new Pen(Color.Gray, 1f))
                        using (StringFormat stringFormat = new StringFormat()
                        {
                            Alignment = StringAlignment.Center,
                            LineAlignment = StringAlignment.Far,
                        })
                        {
                            pen.DashStyle = DashStyle.Dash;
                            graphics.DrawLine(pen, p0, p1);
                            graphics.DrawLine(pen, p1, p2);
                            graphics.DrawLine(pen, p2, originF);
                            pen.DashStyle = DashStyle.Solid;
                            graphics.FillEllipse(brush, originF.X - pointSize / 2, originF.Y - pointSize / 2, pointSize, pointSize);
                            graphics.DrawEllipse(pen, originF.X - pointSize / 2, originF.Y - pointSize / 2, pointSize, pointSize);
                            brush.Color = Color.Black;
                            graphics.DrawString($"({origin.X:F3}, {origin.Y:F3}, {origin.Z:F3})", font, brush, originF.X, originF.Y - 10, stringFormat);
                        }
        }
Example #5
0
        public static void WriteSingle3(this XmlElement rootElement, string name, Single3 value)
        {
            XmlElement element = rootElement.GetOrCreateElement(name);

            element.WriteSingle(_XId, value.X);
            element.WriteSingle(_YId, value.Y);
            element.WriteSingle(_ZId, value.Z);
        }
Example #6
0
 public static void Serialize(Single3 t, IFormatter f)
 {
     f.BeginList(3);
     f.Value(t.x);
     f.Value(t.y);
     f.Value(t.z);
     f.EndList();
 }
Example #7
0
 public Scoped2(T4 t4, Scoped3 scoped3, Func2 func2, Single2 single2, Single3 single3)
 {
     T4      = t4;
     Scoped3 = scoped3;
     Func2   = func2;
     Single2 = single2;
     Single3 = single3;
 }
Example #8
0
        public static Single3 ReadSingle3(this XmlElement rootElement, string name, Single3 defaultValue)
        {
            XmlElement element = rootElement.GetOrCreateElement(name);
            float      x       = element.ReadSingle(_XId, defaultValue.X);
            float      y       = element.ReadSingle(_YId, defaultValue.Y);
            float      z       = element.ReadSingle(_ZId, defaultValue.Z);

            return(new Single3(x, y, z));
        }
Example #9
0
            public bool Equals(Single3 p)
            {
                const float EPSILON = 1e-5f;

                if (!NearlyEqual(x, p.x, EPSILON))
                {
                    return(false);
                }
                if (!NearlyEqual(y, p.y, EPSILON))
                {
                    return(false);
                }
                if (!NearlyEqual(z, p.z, EPSILON))
                {
                    return(false);
                }
                return(true);
            }
Example #10
0
        // ----------------------------------------------------------------------------------------
        #region WireframePointBase

        public virtual void CalculatePointsF(float length, Func <Single3, PointF> func)
        {
            OriginF    = new PointF(float.NaN, float.NaN); // default
            RayEndF    = new PointF(float.NaN, float.NaN); // default
            NormalEndF = new PointF(float.NaN, float.NaN); // default
            if (!Single3.IsNaN(Origin))
            {
                OriginF = func(Origin);
                if (!double.IsNaN(length))
                {
                    if (!Single3.IsNaN(Direction))
                    {
                        RayEndF = func(Origin + length * Direction);
                    }
                    if (!Single3.IsNaN(Normal))
                    {
                        NormalEndF = func(Origin + length * Normal);
                    }
                }
            }
        }
Example #11
0
        // ----------------------------------------------------------------------------------------
        #region Draw

        public PointF Project(Single3 point)
        {
            PointF result = new PointF(float.NaN, float.NaN); // Default value

            if (!Single3.IsNaN(point))
            {
                float zoom = Zoom;
                if (!float.IsNaN(zoom) && zoom > 0d)
                {
                    float biggestSize = BiggestSize;
                    if (!float.IsNaN(biggestSize) && biggestSize > 0d)
                    {
                        Single3 p2 = RotMat * (point - Origin); // 9 multiplications, 6 additions
                        if (Perspective > 0d)
                        {
                            float b = Perspective * p2.Y / biggestSize;
                            zoom /= (1f + b);
                        }
                        result = new PointF(ToSingle(_centerX + zoom * p2.X), ToSingle(_centerY - zoom * p2.Z)); // 2 multiplications, 2 additions
                    }
                }
            }
            return(result);
        }
Example #12
0
 public Func1(T4 t4, Scoped3 scoped3, Single3 single3)
 {
     T4      = t4;
     Scoped3 = scoped3;
     Single3 = single3;
 }
Example #13
0
 public Single2(Single3 single3)
 {
     Single3 = single3;
 }
Example #14
0
 public Single1(Single2 single2, Single3 single3)
 {
     Single2 = single2;
     Single3 = single3;
 }
Example #15
0
        // ----------------------------------------------------------------------------------------
        #region WireframeDimensions

        public void UpdateDimensions(Single3 origin)
        {
            XRange = XRange.Add(origin.X);
            YRange = YRange.Add(origin.Y);
            ZRange = ZRange.Add(origin.Z);
        }
Example #16
0
        void BenchMarkTest(BenchSerializerBase s)
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            var p = new Person
            {
                Age       = 99999,
                FirstName = "Windows",
                LastName  = "Server",
                Sex       = Sex.Male,
            };
            IList <Person> l = Enumerable.Range(1000, 1000).Select(x => new Person {
                Age = x, FirstName = "Windows", LastName = "Server", Sex = Sex.Female
            }).ToArray();

            var integer = 1;
            var v3      = new Single3 {
                x = 12345.12345f, y = 3994.35226f, z = 325125.52426f
            };
            IList <Single3> v3List = Enumerable.Range(1, 100).Select(_ => new Single3 {
                x = 12345.12345f, y = 3994.35226f, z = 325125.52426f
            }).ToArray();
            var largeString = File.ReadAllText(HtmlPath);

            Console.WriteLine("Warming-up"); //Console.WriteLine();
            s.Serialize(p);
            s.Serialize(l);
            s.Serialize(integer); s.Serialize(v3); s.Serialize(largeString); s.Serialize(v3List);

            dryRun = false;

            //Console.WriteLine();
            Console.WriteLine("Small Object(int,string,string,enum) {0} Iteration", Iteration); //Console.WriteLine();

            var c = s.Serialize(p);                                                             //Console.WriteLine();

            Console.WriteLine("Large Array(SmallObject[1000]) {0} Iteration", Iteration);       //Console.WriteLine();

            var C = s.Serialize(l);                                                             //Console.WriteLine();

            Validate("Osaru.MessagePack", p, l, c, C);

            //Console.WriteLine();
            Console.WriteLine("Additional Benchmarks");                                 //Console.WriteLine();

            Console.WriteLine("Int32(1) {0} Iteration", Iteration);                     //Console.WriteLine();

            var W2 = s.Serialize(integer);                                              //Console.WriteLine();

            Console.WriteLine("Vector3(float, float, float) {0} Iteration", Iteration); //Console.WriteLine();

            var X2 = s.Serialize(v3);                                                   //Console.WriteLine();

            Console.WriteLine("HtmlString({0}bytes) {1} Iteration"
                              , Encoding.UTF8.GetByteCount(largeString)
                              , Iteration);                             //Console.WriteLine();

            var Y2 = s.Serialize(largeString);                          //Console.WriteLine();

            Console.WriteLine("Vector3[100] {0} Iteration", Iteration); //Console.WriteLine();

            var Z2 = s.Serialize(v3List);                               //Console.WriteLine();

            Validate2("MsgPack-Cli", W2, integer);
            Validate2("MsgPack-Cli", X2, v3);
            Validate2("MsgPack-Cli", Y2, largeString);
            Validate2("MsgPack-Cli", Z2, v3List);

            //ストップウォッチを止める
            sw.Stop();

            //結果を表示する
            UnityEngine.Debug.LogFormat("[{1}]{0}", sw.Elapsed, s.GetType().Name);
        }
Example #17
0
 public static void WriteSingle3(this Stream stream, Single3 value, bool reverse = false)
 {
     stream.WriteSingle(value.X, reverse);
     stream.WriteSingle(value.Y, reverse);
     stream.WriteSingle(value.Z, reverse);
 }
Example #18
0
 private void SetOrigin(Single3 value)
 {
     _origin = value;
     RefreshImage();
     OriginChanged?.Invoke(this, new EventArgs());
 }