Exemplo n.º 1
0
        private void drawLine(MultiVector line, Color color)
        {
            MultiVector t, d;

            IPNS.GetLineParams(line, out t, out d);

            MultiVector rotAxis  = MultiVector.CrossProduct(Basis.E3, d);
            double      rotAngle = Math.Acos(d.E3);

            if (rotAxis == MultiVector.Zero)
            {
                rotAxis  = Basis.E1;
                rotAngle = 0.0;
            }

            GL.Color3(color);

            GL.PushMatrix();

            GL.Translate(t.E1, t.E2, t.E3);
            GL.Rotate(MathHelper.RadiansToDegrees(rotAngle), rotAxis.E1, rotAxis.E2, rotAxis.E3);

            drawModel(lineVbo);

            GL.PopMatrix();
        }
Exemplo n.º 2
0
        private void drawCircle(MultiVector circle, Color color)
        {
            MultiVector n, c;
            double      r;

            IPNS.GetCircleParams(circle, out n, out c, out r);

            MultiVector rotAxis  = MultiVector.CrossProduct(Basis.E3, n);
            double      rotAngle = Math.Acos(n.E3);

            if (rotAxis == MultiVector.Zero)
            {
                rotAxis  = Basis.E1;
                rotAngle = 0.0;
            }

            GL.Color3(color);

            GL.PushMatrix();

            GL.Translate(c.E1, c.E2, c.E3);
            GL.Rotate(MathHelper.RadiansToDegrees(rotAngle), rotAxis.E1, rotAxis.E2, rotAxis.E3);
            GL.Scale(r, r, r);

            drawModel(circleVbo);

            GL.PopMatrix();
        }
Exemplo n.º 3
0
        private void drawVector(MultiVector vector, Color color)
        {
            GL.Color3(color);

            MultiVector rotAxis  = MultiVector.CrossProduct(Basis.E3, vector);
            double      rotAngle = Math.Acos(vector.E3 / vector.Length);;

            if (rotAxis == MultiVector.Zero)
            {
                rotAxis  = Basis.E1;
                rotAngle = 0.0;
            }


            double length = vector.Length;

            GL.PushMatrix();

            GL.Rotate(MathHelper.RadiansToDegrees(rotAngle), rotAxis.E1, rotAxis.E2, rotAxis.E3);
            GL.Scale(length, length, length);

            drawModel(vectorLineVbo);

            GL.PopMatrix();

            GL.PushMatrix();

            GL.Translate(vector.E1, vector.E2, vector.E3);
            GL.Rotate(MathHelper.RadiansToDegrees(rotAngle), rotAxis.E1, rotAxis.E2, rotAxis.E3);

            drawModel(vectorArrowVbo);

            GL.PopMatrix();
        }
Exemplo n.º 4
0
        private void drawPlane(MultiVector plane, Color color)
        {
            MultiVector n;
            double      d;

            IPNS.GetPlaneParams(plane, out n, out d);

            MultiVector rotAxis  = MultiVector.CrossProduct(Basis.E3, n);
            double      rotAngle = Math.Acos(n.E3);

            if (rotAxis == MultiVector.Zero)
            {
                rotAxis  = Basis.E1;
                rotAngle = 0.0;
            }

            GL.Color3(color);

            GL.PushMatrix();

            GL.Translate(n.E1 * d, n.E2 * d, n.E3 * d);
            GL.Rotate(MathHelper.RadiansToDegrees(rotAngle), rotAxis.E1, rotAxis.E2, rotAxis.E3);

            drawModel(planeVbo);

            GL.PopMatrix();
        }
Exemplo n.º 5
0
        public AlgeoVisualizer()
        {
            AlgeoObjects = new List <AlgeoObject>();

            Eye    = MultiVector.Vector(10, 10, 10);
            Target = MultiVector.Vector(0, 0, 0);
            Up     = MultiVector.Vector(0, 1, 0);

            VectorArrowLength  = 0.5f;
            VectorArrowRadius  = 0.15f;
            VectorArrowQuality = 10;

            PointRadius  = 0.15f;
            PointQuality = 10;

            SphereSegments = 20;
            SphereRings    = 20;

            PlaneInfinity    = 10.0f;
            PlaneLineDensity = 1.0f;

            LineInfinity = 10.0f;

            CircleLines = 40;
        }
Exemplo n.º 6
0
        public AlgeoObject Add(MultiVector value, Color color)
        {
            AlgeoObject ret = new AlgeoObject(value, color);

            Add(ret);
            return(ret);
        }
Exemplo n.º 7
0
        private void drawPointPair(MultiVector pointPair, Color color)
        {
            MultiVector p1, p2;

            IPNS.GetPointPairParams(pointPair, out p1, out p2);

            drawPoint(p1, color);
            drawPoint(p2, color);
        }
Exemplo n.º 8
0
        private void drawPoint(MultiVector point, Color color)
        {
            MultiVector x;

            IPNS.GetPointParams(point, out x);

            GL.Color3(color);

            GL.PushMatrix();

            GL.Translate(x.E1, x.E2, x.E3);
            GL.Scale(PointRadius, PointRadius, PointRadius);

            drawModel(sphereVbo);

            GL.PopMatrix();
        }
Exemplo n.º 9
0
        private void drawSphere(MultiVector sphere, Color color)
        {
            MultiVector c;
            double      r;

            IPNS.GetSphereParams(sphere, out c, out r);

            GL.Color3(color);

            GL.PushMatrix();

            GL.Translate(c.E1, c.E2, c.E3);
            GL.Scale(r, r, r);

            drawModel(sphereVbo);

            GL.PopMatrix();
        }
Exemplo n.º 10
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            var state = OpenTK.Input.Keyboard.GetState();

            if (state[Key.Up])
            {
                alpha += ANGLE_STEP;
            }

            if (state[Key.Down])
            {
                alpha -= ANGLE_STEP;
            }

            if (state[Key.Left])
            {
                beta += ANGLE_STEP;
            }

            if (state[Key.Right])
            {
                beta -= ANGLE_STEP;
            }

            if (state[Key.PageUp])
            {
                distance -= DISTANCE_STEP;
            }

            if (state[Key.PageDown])
            {
                distance += DISTANCE_STEP;
            }

            float y   = distance * (float)Math.Sin(alpha);
            float rxz = distance * (float)Math.Cos(alpha);
            float z   = rxz * (float)Math.Sin(beta);
            float x   = rxz * (float)Math.Cos(beta);

            Visualizer.Eye = MultiVector.Vector(x, y, z);
        }
Exemplo n.º 11
0
        public static void Main(string[] args)
        {
            var win = new AlgeoWindow();

            // Create some points
            MultiVector p1 = IPNS.CreatePoint(2, 3, 0);
            MultiVector p2 = IPNS.CreatePoint(-3, -4, 3);
            MultiVector p3 = IPNS.CreatePoint(1, -5, 0);
            MultiVector p4 = IPNS.CreatePoint(-1, -2, -3);

            // Calculate sphere with four points
            MultiVector s = (p1 ^ p2 ^ p3 ^ p4).Dual;

            // Calculate plane with three points
            MultiVector p = (p1 ^ p2 ^ p3 ^ Basis.E8).Dual;

            // Add points
            win.Visualizer.Add(p1, Color.Yellow);
            win.Visualizer.Add(p2, Color.Yellow);
            win.Visualizer.Add(p3, Color.Yellow);
            win.Visualizer.Add(p4, Color.Orange);

            // Add sphere and plane
            win.Visualizer.Add(s, Color.Gray);
            win.Visualizer.Add(p, Color.Violet);

            // Calculate circle defined by intersection of the sphere and the plane and add it
            win.Visualizer.Add(s ^ p, Color.Yellow);

            // Calculate line through two points and add it
            win.Visualizer.Add((p1 ^ p2 ^ Basis.E8).Dual, Color.White);

            // Add some vectors to visualize the coordinate system
            win.Visualizer.Add(MultiVector.Vector(5, 0, 0), Color.Red);
            win.Visualizer.Add(MultiVector.Vector(0, 5, 0), Color.Green);
            win.Visualizer.Add(MultiVector.Vector(0, 0, 5), Color.Blue);

            // Run
            win.Run(25);
        }
Exemplo n.º 12
0
 public AlgeoObject(MultiVector value, Color color)
 {
     this.value = value.Clone();
     this.Color = color;
 }