Ejemplo n.º 1
0
        protected override void Init()
        {
            base.Init();

            position = new double[] { 0, 0, 0 };
            scale    = new ExpressionD("1");
            trans    = new VectorExpr(new string[] { "0", "0", "0" });
            color    = new VectorExpr(new string[] { "1", "0", "1", "0" });
            origin   = new VectorExpr(new string[] { "0", "0", "0" });
            rot      = new VectorExpr(new string[] { "0", "0", "0" });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns an array of points representing a graph in polar coordinates
        /// </summary>
        /// <param name="expression">What to graph</param>
        /// <param name="start">Theta value to begin at</param>
        /// <param name="stop">Theta value to end at</param>
        /// <param name="step">Theta resolution</param>
        /// <returns></returns>
        public static double[,] GraphPolar(ExpressionD expression, double start, double stop, double step)
        {
            if (start >= stop || step <= 0)
            {
                throw new Exception("Cannot graph polar, invalid arguments");
            }

            double[,] result;
            ArrayList points = new ArrayList();

            //Perform calculations
            ExpressionD.AddSymbol("i", 0);
            int    index = 0;
            double theta;

            for (double i = start; i < stop; i += step)
            {
                ExpressionD.SetSymbolValue("i", i * Math.PI / 180.0);
                theta = i * Math.PI / 180.0;

                points.Add(new Point3(
                               expression.Evaluate() * Math.Sin(theta),
                               expression.Evaluate() * Math.Cos(theta),
                               0
                               ));

                index++;
            }
            ExpressionD.RemoveSymbol("i");

            //Convert
            result = new double[3, points.Count];
            int count = 0;

            foreach (Point3 p in points)
            {
                result[0, count] = p.x;
                result[1, count] = p.y;
                result[2, count] = p.z;
                count++;
            }

            return(result);
        }
Ejemplo n.º 3
0
        public override void Recalculate()
        {
            //base.Recalculate();

            //Setup expression values
            ExpressionD.AddSymbol("dist", 0);
            ExpressionD.AddSymbol("length", length);
            ExpressionD.AddSymbol("xslope", 0);
            ExpressionD.AddSymbol("yslope", 0);
            ExpressionD.AddSymbol("zslope", 0);

            //Set the properties of the child objects
            foreach (PenVertex penVert in vertecies)
            {
                //Set variables
                ExpressionD.SetSymbolValue("dist", penVert.distance);
                ExpressionD.SetSymbolValue("xslope", penVert.slope[0]);
                ExpressionD.SetSymbolValue("yslope", penVert.slope[1]);
                ExpressionD.SetSymbolValue("zslope", penVert.slope[2]);

                //Calculate
                color.Recalculate();

                //Set
                ((SimpleObject3)penVert.obj).Recalculate();
                ((SimpleObject3)penVert.obj).SetColor(color.Values());
                ((SimpleObject3)penVert.obj).ScaleGeo(scale.Evaluate());
                ((SimpleObject3)penVert.obj).TranslateGeo(penVert.x, penVert.y, penVert.z);
            }

            //Remove them as the program leaves scope
            ExpressionD.RemoveSymbol("dist");
            ExpressionD.RemoveSymbol("length");
            ExpressionD.RemoveSymbol("xslope");
            ExpressionD.RemoveSymbol("yslope");
            ExpressionD.RemoveSymbol("zslope");
        }
Ejemplo n.º 4
0
 public override void Draw()
 {
     foreach (PenVertex penVert in vertecies)
     {
         double dist = speed * ExpressionD.GetSymbolValue("time");
         double sdfs = penVert.distance;
         if (speed >= 0)
         {
             if (penVert.distance < dist)
             {
                 penVert.obj.Draw();
             }
             else
             {
                 vertecies.Reset();
                 break;
             }
         }
         else
         {
             penVert.obj.Draw();
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the expression at the given index
 /// </summary>
 /// <param name="index"></param>
 /// <param name="expr"></param>
 public void SetExprAt(int index, string expr)
 {
     expressions[index] = new ExpressionD(expr);
 }
Ejemplo n.º 6
0
        public override void SetAttributes(Dictionary <string, string> args)
        {
            base.SetAttributes(args);

            #region Set Rotational Values
            if (args.ContainsKey("rotation"))
            {
                rot = new VectorExpr(new string[] {
                    args["rotation"], args["rotation"], args["rotation"]
                });
            }

            if (args.ContainsKey("xrotation"))
            {
                rot.SetExprAt(0, args["xrotation"]);
            }

            if (args.ContainsKey("yrotation"))
            {
                rot.SetExprAt(1, args["yrotation"]);
            }

            if (args.ContainsKey("zrotation"))
            {
                rot.SetExprAt(2, args["zrotation"]);
            }
            #endregion

            #region Set Color Values
            if (args.ContainsKey("color"))
            {
                color = new VectorExpr(new string[] {
                    args["color"], args["color"], args["color"], args["color"]
                });
            }

            if (args.ContainsKey("rcolor"))
            {
                color.SetExprAt(0, args["rcolor"]);
            }

            if (args.ContainsKey("gcolor"))
            {
                color.SetExprAt(1, args["gcolor"]);
            }

            if (args.ContainsKey("bcolor"))
            {
                color.SetExprAt(2, args["bcolor"]);
            }

            if (args.ContainsKey("acolor"))
            {
                color.SetExprAt(3, args["acolor"]);
            }
            #endregion

            if (args.ContainsKey("scale"))
            {
                scale = new ExpressionD(args["scale"]);
            }
        }