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; }
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); }
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); }