forked from Dan-Piker/K2Goals
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlasticAnchor.cs
39 lines (36 loc) · 1 KB
/
PlasticAnchor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Rhino.Geometry;
namespace KangarooSolver.Goals
{
public class PlasticAnchor : GoalObject
{
public Point3d Location;
public double Limit;
public PlasticAnchor(Point3d P, double R, double k)
{
PPos = new Point3d[1] { P };
Move = new Vector3d[1];
Weighting = new double[1] { k };
Location = P;
Limit = R;
}
public override void Calculate(List<KangarooSolver.Particle> p)
{
Point3d ThisPt = p[PIndex[0]].Position;
Vector3d Between = Location - ThisPt;
Move[0] = Between;
double stretch = Between.Length - Limit;
if (stretch > 0)
{
Between.Unitize();
Between *= stretch;
Location -= Between;
Move[0] -= Between;
}
}
}
}