예제 #1
0
 public FixedPoint(FixedPoint f)
     : this(f.U, f.V)
 {
     m_s = f[0];
 }
예제 #2
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
        public IGroup CreateOuterCurves()
        {
            if (FindGroup("Outer") != null)
                return FindGroup("Outer");

            CurveGroup outer = new CurveGroup("Outer", this);
            //int nLayer = View.AddLayer("Outer", Color.MistyRose, true);
            FixedPoint[] corners = new FixedPoint[4];
            corners[0] = new FixedPoint(0, 0);
            corners[1] = new FixedPoint(0, 1);
            corners[2] = new FixedPoint(1, 1);
            corners[3] = new FixedPoint(1, 0);
            FixedPoint middle = new FixedPoint(0.5, 0.5);

            FixedPoint[] lu = new FixedPoint[] { new FixedPoint(corners[0]), new FixedPoint(corners[1]) };
            FixedPoint[] hd = new FixedPoint[] { new FixedPoint(corners[1]), new FixedPoint(corners[2]) };
            FixedPoint[] le = new FixedPoint[] { new FixedPoint(corners[3]), new FixedPoint(corners[2]) };
            FixedPoint[] ft = new FixedPoint[] { new FixedPoint(corners[0]), new FixedPoint(corners[3]) };

            outer.Add(new MouldCurve("Luff", this, lu));
            outer.Add(new MouldCurve("Leech", this, le));
            outer.Add(new MouldCurve("Head", this, hd));
            outer.Add(new MouldCurve("Foot", this, ft));

            Add(outer);

            return outer;
            //LinearPath[] paths = new LinearPath[4];
            //Entity[] es;
            //for (int i = 0; i < 4; i++)
            //{
            //	Color c = Color.FromArgb(255 * (i % 2), 122 * (i % 3), 85 * i);
            //	//	LinearPath p = new LinearPath(GetPathPoints(outer[i], 100));
            //	//p.LayerIndex = nLayer;
            //	es = outer[i].CreateEntity(false);
            //	foreach (Entity e in es)
            //	{
            //		e.LayerIndex = nLayer;
            //		View.Add(e);
            //	}
            //	//m_viewleft.Entities.Add(new PointCloud(GetPoints(outer[i].xFits), 5f, Color.Tomato));

            //}
            //s.Layout.Add(outer);

            ////SurfaceCurve gir = null;
            //for (int i = 0; i < 2; i++)
            //{
            //	CurveGroup girths = new CurveGroup(i == 0 ? "Girths" : "Virths", s);
            //	nLayer = View.AddLayer(girths.Label, i == 0 ? Color.SteelBlue : Color.IndianRed, i == 0);
            //	for (double dg = 0.0; dg < 1; dg += 0.1)
            //	{
            //		IFitPoint[] gir = new IFitPoint[2];
            //		gir[1] = new CurvePoint(1, outer[2 * i + 1], dg);

            //		//gir[1] = new FixedPoint(.3, .3);
            //		if (i == 0)
            //			gir[0] = new SlidePoint(0, outer[2 * i], dg);
            //		else
            //			gir[0] = new CurvePoint(0, outer[2 * i], dg);

            //		Geodesic girth = new Geodesic(String.Format("{0}ir-{1:##0}%", i == 0 ? "G" : "V", dg * 100), s, gir);
            //		if (girth.xGeos != null)
            //		{
            //			//gir = girth;
            //			//m_viewleft.Entities.Add(new LinearPath(GetPathPoints(girth, 100), Color.DarkGoldenrod));
            //			//LinearPath p = new LinearPath(GetPathPoints(girth, 100));
            //			//p.LayerIndex = nLayer;
            //			es = girth.CreateEntity(false);
            //			foreach (Entity e in es)
            //			{
            //				e.LayerIndex = nLayer;
            //				View.Add(e);
            //			}
            //			//m_viewleft.Entities.Add(new PointCloud(GetPoints(girth.xGeos), 5f, Color.Tomato));
            //			girths.Add(girth);
            //		}
            //	}
            //	s.Layout.Add(girths);
            //}

            //CurveGroup mid = new CurveGroup("Mids", s);
            //nLayer = View.AddLayer("Mids", Color.GreenYellow, true);
            //SurfaceCurve x = new SurfaceCurve("CtoH", s, new IFitPoint[] { corners[1], middle, new CurvePoint(1, outer["Leech"], 0.0) });
            //mid.Add(x);
            //es = x.CreateEntity(false);
            //foreach (Entity e in es)
            //{
            //	e.LayerIndex = nLayer;
            //	View.Add(e);
            //}

            //s.Layout.Add(mid);
        }
예제 #3
0
        public virtual bool InsertPoint(PointF mouse, Transformer WorldToScreen, out int nIndex)
        {
            double s = 0.5, h = 0;
            Vect2 uv = new Vect2();

            //find the closest point to the mouse click
            if (!mClosest(ref s, ref mouse, ref uv, ref h, WorldToScreen, 1e-3))//failed to find point to insert
            {
                nIndex = -1;
                return false;
            }

            //find bracketing fitpoints
            int i;
            for (i = 0; i < FitPoints.Length; i++)
            {
                if (FitPoints[i].S > s)
                    break;
            }

            //uVal(s, ref uv);
            //create a new fixed point for insertion
            FixedPoint fp = new FixedPoint(s, uv);
            List<IFitPoint> fits = new List<IFitPoint>(FitPoints.Length + 1);
            //copy the existing fitpoint array
            fits.AddRange(FitPoints);
            //insert the new point
            fits.Insert(i, fp);
            //store the new fitpoint array for refitting
            FitPoints = fits.ToArray();
            nIndex = i;
            return true;
        }