public MassData(iShape shape, float density)
        {
            float area;

            if (shape is Circle)
            {
                area  = (shape as Circle).Radius;
                area *= area * (float)Math.PI;
            }
            else
            {
                area = (shape as Rectangle).Size.X * (shape as Rectangle).Size.Y;
            }
            Mass     = density * area;
            Inv_Mass = Mass == 0 ? 0 : 1 / Mass;
        }
        public static IShape MakeShape(string shapeType)
        {
            IShape shape = null;

            switch (shapeType.ToLower())
            {
            case "i":
                shape = new iShape();
                break;

            case "j":
                shape = new jShape();
                break;

            case "l":
                shape = new lShape();
                break;

            case "o":
                shape = new oShape();
                break;

            case "s":
                shape = new sShape();
                break;

            case "t":
                shape = new tShape();
                break;

            case "z":
                shape = new zShape();
                break;

            case "test":
                shape = new testShape();
                break;

            default:
                throw new ArgumentException("Invalid shape name");
            }

            return(shape);
        }
Exemple #3
0
 /// <summary>
 /// Add new Shapes (either composites or leafs) to the shape
 /// </summary>
 /// <param name="shapeToAddToCurrentShape">The new shape to add</param>
 public void AddToShape(iShape shapeToAddToCurrentShape)
 {
     shapeList.Add(shapeToAddToCurrentShape);
 }