public bool InnerPoint_LineSeg(Point2d P)
        {
            Point2d Pf  = footPoint(P);
            double  Dab = Pa.DistanceTo(Pb);
            double  Daf = Pa.DistanceTo(Pf);
            double  Dbf = Pb.DistanceTo(Pf);

            return(Math.Min(Daf, Dbf) < Dab);
        }
예제 #2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var points = new Point3d[]
            {
                new Point3d(1, 1, 0),
                new Point3d(5, 1, 0),
                new Point3d(5, 5, 0),
                new Point3d(9, 5, 0)
            };

            var xy_plane = Plane.WorldXY;

            var points2d = new List <Point2d>();

            foreach (var point3d in points)
            {
                double x, y;
                if (xy_plane.ClosestParameter(point3d, out x, out y))
                {
                    var point2d = new Point2d(x, y);
                    if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last <Point2d>()) > RhinoMath.SqrtEpsilon)
                    {
                        points2d.Add(point2d);
                    }
                }
            }

            doc.Objects.AddLeader(xy_plane, points2d);
            doc.Views.Redraw();
            return(Result.Success);
        }
예제 #3
0
    public static Result Leader(RhinoDoc doc)
    {
        var points = new Point3d[]
        {
          new Point3d(1, 1, 0),
          new Point3d(5, 1, 0),
          new Point3d(5, 5, 0),
          new Point3d(9, 5, 0)
        };

        var xy_plane = Plane.WorldXY;

        var points2d = new List<Point2d>();
        foreach (var point3d in points)
        {
          double x, y;
          if (xy_plane.ClosestParameter(point3d, out x, out y))
          {
        var point2d = new Point2d(x, y);
        if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last<Point2d>()) > RhinoMath.SqrtEpsilon)
          points2d.Add(point2d);
          }
        }

        doc.Objects.AddLeader(xy_plane, points2d);
        doc.Views.Redraw();
        return Result.Success;
    }
        public void MoveTowardsPatch(List <Plant> plants)
        {
            Point2d loc    = new Point2d(location_x, location_y);
            Point2d target = new Point2d(target_x, target_y);

            List <Point2d> possiblePlants = new List <Point2d>();

            foreach (Plant p in plants)
            {
                Point2d plant = new Point2d(p.locX, p.locY);
                if (plant.DistanceTo(loc) < visibility)
                {
                    if (plant.DistanceTo(loc) < target.DistanceTo(plant))
                    {
                        possiblePlants.Add(new Point2d(p.locX, p.locY));
                    }
                }
            }

            if (possiblePlants.Count == 0)
            {
                MoveTowardsTarget();
            }
            else
            {
                Point2d chosenPlant = Point2d.Unset;
                if (possiblePlants.Count == 1)
                {
                    chosenPlant = possiblePlants[0];
                }
                else
                {
                    chosenPlant = (from p in possiblePlants orderby p.DistanceTo(loc) select p).ToList()[0];
                }

                Vector2d direction = chosenPlant - loc;
                direction.Unitize();

                loc       += direction;
                location_x = (int)Math.Round(loc.X);
                location_y = (int)Math.Round(loc.Y);

                ClampPositions();
            }
        }
예제 #5
0
        public static Transform2 Transform(Point2d source1, Point2d source2, Point2d target1, Point2d target2)
        {
            double sourceLen = source1.DistanceTo(source2);
            double targetLen = target1.DistanceTo(target2);

            Vector2d vsource = source2 - source1;
            Vector2d vtarget = target2 - target1;

            double angle = vsource.AngleTo(vtarget);

            return(Transform2.Translate(target1.X, target1.Y)
                   .Concat(Transform2.Scale(targetLen / sourceLen))
                   .Concat(Transform2.Rotate(angle))
                   .Concat(Transform2.Translate(-source1.X, -source1.Y)));
        }
예제 #6
0
 public Line2(Point2d p0, Point2d p1)
     : this(p0, 0, p1, p0.DistanceTo(p1))
 {
 }
예제 #7
0
 public Segment2(Point2d p0, Point2d p1)
     : this(p0, 0, p1, p0.DistanceTo(p1))
 {
 }
예제 #8
0
        internal static IfcBoundedCurve convCurve(DatabaseIfc db, Curve crv, IfcCartesianPoint optStrt, bool twoD, out IfcCartesianPoint end)
        {
            double tol = db.Tolerance;

            end = null;
            Curve c = crv.DuplicateCurve();

            if (c.IsLinear(tol))
            {
                if (twoD)
                {
                    end = new IfcCartesianPoint(db, new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                }
                else
                {
                    end = new IfcCartesianPoint(db, c.PointAtEnd);
                }
                if (optStrt == null)
                {
                    if (twoD)
                    {
                        optStrt = new IfcCartesianPoint(db, new Point2d(c.PointAtStart.X, c.PointAtStart.Y));
                    }
                    else
                    {
                        optStrt = new IfcCartesianPoint(db, c.PointAtStart);
                    }
                }
                return(new IfcPolyline(optStrt, end));
            }
            ArcCurve ac = c as ArcCurve;

            if (ac != null)
            {
                return(new IfcTrimmedCurve(db, ac.Arc, twoD, optStrt, out end));
            }
            Arc arc = Arc.Unset;

            if (c.TryGetArc(out arc, tol))
            {
                return(new IfcTrimmedCurve(db, arc, twoD, optStrt, out end));
            }

            Polyline pl = new Polyline();

            if (c.TryGetPolyline(out pl))
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    if (twoD)
                    {
                        return(new IfcIndexedPolyCurve(new IfcCartesianPointList2D(db, pl.ConvertAll(x => new Point2d(x.X, x.Y)))));
                    }
                    else
                    {
                        return(new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, pl)));
                    }
                }
                List <IfcCartesianPoint> cps = new List <IfcCartesianPoint>();
                if (twoD)
                {
                    Point2d p = new Point2d(pl[0].X, pl[0].Y), n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count - 1; icounter++)
                    {
                        n = new Point2d(pl[icounter].X, pl[icounter].Y);
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                    n = new Point2d(pl[pl.Count - 1].X, pl[pl.Count - 1].Y);
                    if (n.DistanceTo(p) > tol)
                    {
                        if (pl.IsClosed)
                        {
                            cps.Add(cps[0]);
                        }
                        else
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                        }
                    }
                }
                else
                {
                    Point3d p = pl[0], n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count; icounter++)
                    {
                        n = pl[icounter];
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                }
                return(new IfcPolyline(cps));
            }
            PolyCurve plc = c as PolyCurve;

            if (plc != null)
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    IfcIndexedPolyCurve ipc = IfcIndexedPolyCurve.Convert(db, plc, twoD);
                    if (ipc != null)
                    {
                        return(ipc);
                    }
                }
                return(new IfcCompositeCurve(db, plc, twoD));
            }
            if (db.mRelease != ReleaseVersion.IFC2x3)
            {
                NurbsCurve nc = c as NurbsCurve;
                if (nc != null)
                {
                    if (nc.IsRational)
                    {
                        return(new IfcRationalBSplineCurveWithKnots(db, nc, twoD));
                    }
                    return(new IfcBSplineCurveWithKnots(db, nc, twoD));
                }
            }

            return(null);
        }
예제 #9
0
        internal static IfcBoundedCurve convCurve(DatabaseIfc db, Curve crv, IfcCartesianPoint optStrt, bool twoD, out IfcCartesianPoint end)
        {
            double tol = db.Tolerance;
            end = null;
            Curve c = crv.DuplicateCurve();
            if (c.IsLinear(tol))
            {
                if (twoD)
                    end = new IfcCartesianPoint(db, new Point2d(c.PointAtEnd.X, c.PointAtEnd.Y));
                else
                    end = new IfcCartesianPoint(db, c.PointAtEnd);
                if (optStrt == null)
                {
                    if (twoD)
                        optStrt = new IfcCartesianPoint(db, new Point2d(c.PointAtStart.X, c.PointAtStart.Y));
                    else
                        optStrt = new IfcCartesianPoint(db, c.PointAtStart);
                }
                return new IfcPolyline(optStrt, end);
            }
            ArcCurve ac = c as ArcCurve;
            if (ac != null)
                return new IfcTrimmedCurve(db, ac.Arc, twoD, optStrt, out end);
            Arc arc = Arc.Unset;
            if (c.TryGetArc(out arc, tol))
                return new IfcTrimmedCurve(db, arc, twoD, optStrt, out end);

            Polyline pl = new Polyline();
            if (c.TryGetPolyline(out pl))
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    if (twoD)
                        return new IfcIndexedPolyCurve(new IfcCartesianPointList2D(db, pl.ConvertAll(x => new Point2d(x.X, x.Y))));
                    else
                        return new IfcIndexedPolyCurve(new IfcCartesianPointList3D(db, pl));
                }
                List<IfcCartesianPoint> cps = new List<IfcCartesianPoint>();
                if (twoD)
                {
                    Point2d p = new Point2d(pl[0].X, pl[0].Y), n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count - 1; icounter++)
                    {
                        n = new Point2d(pl[icounter].X, pl[icounter].Y);
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                    n = new Point2d(pl[pl.Count - 1].X, pl[pl.Count - 1].Y);
                    if (n.DistanceTo(p) > tol)
                    {
                        if (pl.IsClosed)
                            cps.Add(cps[0]);
                        else
                            cps.Add(new IfcCartesianPoint(db, n));
                    }
                }
                else
                {
                    Point3d p = pl[0], n;
                    cps.Add(new IfcCartesianPoint(db, p));
                    for (int icounter = 1; icounter < pl.Count; icounter++)
                    {
                        n = pl[icounter];
                        if (n.DistanceTo(p) > tol)
                        {
                            cps.Add(new IfcCartesianPoint(db, n));
                            p = n;
                        }
                    }
                }
                return new IfcPolyline(cps);
            }
            PolyCurve plc = c as PolyCurve;
            if (plc != null)
            {
                if (db.mRelease != ReleaseVersion.IFC2x3 && db.mRelease != ReleaseVersion.IFC4)
                {
                    IfcIndexedPolyCurve ipc = IfcIndexedPolyCurve.Convert(db, plc, twoD);
                    if (ipc != null)
                        return ipc;
                }
                return new IfcCompositeCurve(db, plc, twoD);
            }
            if (db.mRelease != ReleaseVersion.IFC2x3)
            {
                NurbsCurve nc = c as NurbsCurve;
                if (nc != null)
                {
                    if (nc.IsRational)
                        return new IfcRationalBSplineCurveWithKnots(db, nc, twoD);
                    return new IfcBSplineCurveWithKnots(db, nc, twoD);
                }
            }

            return null;
        }
예제 #10
0
        public void Process(List <GH_Point> points, List <GH_Vector> vectors, GH_Surface surface)
        {
            var planes  = Param["Pl"] as List <GH_Plane>;
            var h       = (double)Param["h"];
            var k       = (double)Param["k"];
            var a       = (double)Param["a"];
            var e       = (bool)Param["e"];
            var funnel  = (bool)Param["F"];
            var reverse = (bool)Param["r"];

            var    nv = new GH_Vector();
            double u1, v1, u2, v2;

            u1 = u2 = v1 = v2 = 0.0d;

            for (int i = 0; i < points.Count; i++)
            {
                foreach (var pl in planes)
                {
                    var o     = pl.Value.Origin;
                    var currP = points[i].Value;

                    if (surface.IsValid)
                    {
                        if (!e)
                        {
                            surface.Face.ClosestPoint(currP, out u1, out v1);
                            var surfPl = new Plane(currP, surface.Face.NormalAt(u1, v1));

                            Point3d remap;
                            surfPl.RemapToPlaneSpace(pl.Value.Origin, out remap);

                            var dir = surfPl.PointAt(remap.X, remap.Y) - surfPl.Origin;
                            dir.Unitize();

                            surface.Face.ClosestPoint(pl.Value.Origin, out u2, out v2);

                            Point2d uv1 = new Point2d(u1, v1);
                            Point2d uv2 = new Point2d(u2, v2);

                            var dis = uv1.DistanceTo(uv2);
                            dir *= (k / Math.Pow(dis, h));

                            var tan = Vector3d.CrossProduct(dir, surface.Face.NormalAt(u1, v1));
                            tan.Unitize();
                            tan *= a / dis;

                            Vector3d rotation = dir + tan;
                            rotation.Unitize();

                            Basis offCheck = new Basis(new GH_Point(currP + rotation));
                            if (!Algos.CheckIfOffSurface(offCheck, surface))
                            {
                                nv.Value += rotation;
                            }
                        }
                        else
                        {
                            surface.Face.ClosestPoint(currP, out u1, out v1);
                            surface.Face.ClosestPoint(o, out u2, out v2);

                            var p1 = new Point2d(u1, v1);
                            var p2 = new Point2d(u2, v2);

                            var c = surface.Face.ShortPath(p1, p2, 0.001d);
                            var v = c.TangentAtStart;

                            nv = new GH_Vector(v);
                            nv.Value.Unitize();
                            nv.Value *= (k / Math.Pow(c.GetLength(), 1d + h));

                            var sn   = surface.Face.NormalAt(u1, v1);
                            var sncv = Vector3d.CrossProduct(sn, v);
                            sncv.Unitize();
                            sncv *= a / c.GetLength();

                            nv.Value += sncv;
                        }

                        if (reverse)
                        {
                            surface.Face.ClosestPoint(currP, out u1, out v1);
                            var surfN = surface.Face.NormalAt(u1, v1);

                            var v = Vector3d.CrossProduct(surfN, nv.Value);
                            v.Unitize();
                            v       *= nv.Value.Length;
                            nv.Value = v;
                        }
                    }
                    else
                    {
                        nv = new GH_Vector(o - currP);
                        nv.Value.Unitize();
                        nv.Value *= (k / Math.Pow(currP.DistanceTo(o), 1d + h));

                        if (funnel)
                        {
                            Point3d outP;
                            pl.Value.RemapToPlaneSpace(currP, out outP);
                            nv.Value *= Math.Sign(outP.Z);
                        }

                        Point3d sign;
                        pl.Value.RemapToPlaneSpace(currP, out sign);

                        if (sign.X != 0 && sign.Y != 0)
                        {
                            Vector3d tan;

                            tan = new Vector3d(-sign.Y, sign.X, 0);

                            var tanAtPl = pl.Value.PointAt(tan.X, tan.Y, 0);
                            var tanAtO  = tanAtPl - o;

                            tanAtO   *= a / Math.Pow(tan.Length, 2d + h);
                            nv.Value += tanAtO;
                        }
                    }

                    vectors[i].Value += nv.Value;
                }
            }
        }
        public Point2d IntersectionPoint__x(FuncApproximation F1, FuncApproximation F2, Point2d PTX, Point2d PTXdummy, bool DispB)
        {
            this.F1 = F1; this.F2 = F2;
            Point2d     PT = PTX, PTnxt = new Point2d(-9999, -9999);
            bool        B = F1.XYmode;
            DenseMatrix M = new DenseMatrix(2, 2), Minv;
            DenseVector V = new DenseVector(2);
            double      a = 0.0, b = 0.0, c = 0.0, a1 = 0.0, b1 = 0.0, c1 = 0.0, d = 0;
            int         loop;

            Mat resImg = null;

            if (DispB)
            {
                resImg = ImgCheck.CvtColor(ColorConversionCodes.GRAY2BGR);   //Gray->Color変換
                WriteLine();
            }
            for (loop = 0; loop < 20; loop++) //Up to 20 times
            {
                int r = 2 + loop * 2;
                if (loop == 0)
                {
                    F1.GetTangent(ref a, ref b, ref c);
                    F2.GetTangent(ref a1, ref b1, ref c1);
                }
                else
                {
                    double e = Min(d * 0.1, 1.0);
                    F1.GetTangent1(PT, e, ref a, ref b, ref c);
                    F2.GetTangent1(PT, e, ref a1, ref b1, ref c1);
                }
                if (DispB)
                {
                    for (int x = 0; x < ImgCheck.Width; x += 20)
                    {
                        Point P1 = new Point(x, -a * x + c);
                        Point P2 = P1 + (new Point(r, r));
                        resImg.Rectangle(P1, P2, Scalar.Blue, 3);
                    }
                    for (int y = 0; y < ImgCheck.Height; y += 20)
                    {
                        Point P1 = new Point(-b1 * y + c1, y);
                        Point P2 = P1 + (new Point(r, r));
                        resImg.Rectangle(P1, P2, Scalar.Red, 3);
                    }
                    using (new Window("IntersectionPoint", WindowMode.KeepRatio, resImg)){ Cv2.WaitKey(0); }
                }
                bool matrixB = true;
                if (Abs(a) < 0.1)
                {
                    PTnxt.Y = c / b;   PTnxt.X = F2.RegXY.Estimate(PTnxt.Y); matrixB = false;
                }
                if (Abs(a1) < 0.1)
                {
                    PTnxt.Y = c1 / b1; PTnxt.X = F1.RegXY.Estimate(PTnxt.Y); matrixB = false;
                }
                if (Abs(b) < 0.1)
                {
                    PTnxt.X = c / a;   PTnxt.Y = F2.RegXY.Estimate(PTnxt.X); matrixB = false;
                }
                if (Abs(b1) < 0.1)
                {
                    PTnxt.X = c1 / a1; PTnxt.Y = F1.RegXY.Estimate(PTnxt.X); matrixB = false;
                }

                if (DispB)
                {
                    string st = "IntersectionPoint loop:" + loop;
                    st += string.Format(" a:{0:0.0000} b:{1:0.0000} c:{2:0.0000}", a, b, c);
                    st += string.Format(" a1:{0:0.0000} b1:{1:0.0000} c1:{2:0.0000} ", a1, b1, c1);
                    st += matrixB? "..": "◆";
                    st += string.Format("PT:(X:{0:0.0},Y:{1:0.0}) PTnxt:(X:{2:0.0},Y:{3:0.0})", PT.X, PT.Y, PTnxt.X, PTnxt.Y);
                    WriteLine(st);
                }

                if (matrixB)
                {
                    M[0, 0] = a; M[0, 1] = b; V[0] = c;
                    M[1, 0] = a1; M[1, 1] = b1; V[1] = c1;

                    Minv    = (DenseMatrix)M.Inverse();
                    V       = (DenseVector)Minv.Multiply(V);
                    PTnxt.X = V[0]; PTnxt.Y = V[1];
                }
                if (DispB)
                {
                    Point P1 = (Point)PTnxt;
                    Point P2 = P1 + (new Point(r * 5, r * 5));
                    resImg.Rectangle(P1, P2, Scalar.Green, 3);
                    using (new Window("IntersectionPoint", WindowMode.KeepRatio, resImg)){ Cv2.WaitKey(0); }
                }
                d = PT.DistanceTo(PTnxt);
                if (d < 1.0e-1)
                {
                    break;
                }
                PT = PTnxt;
            }
            return(PT);
        }
예제 #12
0
        /// <summary>
        ///     Arco que pasa por los puntos <c>pinicial</c>, <c>ppaso</c>, <c>pfinal</c>.
        /// </summary>
        /// <exception cref="PuntosAlineadosException">
        ///     Indica que los puntos estan
        ///     alineados.
        /// </exception>
        public static CircleArc2 ThreePoints(Point2d p1, Point2d pp, Point2d p2)
        {
            Point2d pcenter = GetCenter(p1, pp, p2);

            double radius = pcenter.DistanceTo(p1);

            Vector2d v1     = p1.Sub(pcenter);
            Vector2d vp     = pp.Sub(pcenter);
            Vector2d v2     = p2.Sub(pcenter);
            double   alpha1 = v1.Angle;
            double   alphap = vp.Angle;
            double   alpha2 = v2.Angle;

            {
                // Se prueba el sentido CCW, alpha1 < alphap < alpha2
                double a1 = alpha1;
                double ap = alphap;
                double a2 = alpha2;
                while (ap < a1)
                {
                    ap += 2 * SysMath.PI;
                }
                while (a2 < ap)
                {
                    a2 += 2 * SysMath.PI;
                }
                if (a2 - a1 > 2 * SysMath.PI)
                {
                    // Se ha dado mas de una vuelta, solucion no valida.
                }
                else
                {
                    return(NewArcWithAdvance(pcenter, radius, AngleUtils.Ensure0To2Pi(a1), a2 - a1));
                }
            }

            {
                // Se prueba el sentido CW, alpha1 > alphap > alpha2
                double a1 = alpha1;
                double ap = alphap;
                double a2 = alpha2;
                while (ap > a1)
                {
                    ap -= 2 * SysMath.PI;
                }
                while (a2 > ap)
                {
                    a2 -= 2 * SysMath.PI;
                }
                if (a1 - a2 > 2 * SysMath.PI)
                {
                    // Se ha dado mas de una vuelta, solucion no valida.
                }
                else
                {
                    return(NewArcWithAdvance(pcenter, radius, AngleUtils.Ensure0To2Pi(a1), a2 - a1));
                }
            }

            throw new Exception();

#if false
            double alpha2 = vecMath.Angle(v1, v2);

            alpha1 = AngleUtils.Ensure0To2Pi(alpha1);

            // Existen 2 soluciones que dependen de angulo de pp:
            //  si alpha2 > 0 : alpha2 y alpha2 - 2*PI
            //  si alpha2 < 0 : alpha2 y alpha2 + 2*PI

            if (alpha2 > 0)
            {
                double alpha3 = vecMath.Angle(pp);
            }
            else
            {
            }
            return(NewArcWithAdvance(pcenter, radius, alpha1, alpha2));
#endif
        }
예제 #13
0
        public void Process(List <GH_Point> points, List <GH_Vector> vectors, GH_Surface surface)
        {
            var sp = Param["SP"] as List <GH_Point>;
            var h  = (double)Param["h"];
            var k  = (double)Param["k"];
            var e  = (bool)Param["e"];

            GH_Vector nv = new GH_Vector();
            double    u1, v1, u2, v2;

            u1 = u2 = v1 = v2 = 0.0d;

            for (int i = 0; i < points.Count; i++)
            {
                foreach (var p in sp)
                {
                    if (surface.IsValid)
                    {
                        if (!e)
                        {
                            surface.Face.ClosestPoint(points[i].Value, out u1, out v1);
                            var surfPl = new Plane(points[i].Value, surface.Face.NormalAt(u1, v1));

                            Point3d remap;
                            surfPl.RemapToPlaneSpace(p.Value, out remap);

                            var dir = surfPl.PointAt(remap.X, remap.Y) - surfPl.Origin;
                            dir.Unitize();

                            surface.Face.ClosestPoint(p.Value, out u2, out v2);

                            Point2d uv1 = new Point2d(u1, v1);
                            Point2d uv2 = new Point2d(u2, v2);

                            var dis = uv1.DistanceTo(uv2);
                            dir *= (k / Math.Pow(dis, h));

                            nv.Value += dir;
                        }
                        else
                        {
                            surface.Face.ClosestPoint(points[i].Value, out u1, out v1);
                            surface.Face.ClosestPoint(p.Value, out u2, out v2);

                            var p1 = new Point2d(u1, v1);
                            var p2 = new Point2d(u2, v2);

                            var c = surface.Face.ShortPath(p1, p2, 0.001d);
                            var v = c.TangentAtStart;

                            nv = new GH_Vector(v);
                            nv.Value.Unitize();
                            nv.Value *= (k / Math.Pow(c.GetLength(), 1d + h));
                        }
                    }
                    else
                    {
                        nv = new GH_Vector(p.Value - points[i].Value);
                        nv.Value.Unitize();
                        nv.Value *= (k / Math.Pow(points[i].Value.DistanceTo(p.Value), 1d + h));
                    }

                    vectors[i].Value += nv.Value;
                }
            }
        }