algorithmic modeling for Rhino
hi,
I am having trouble iterating a translation of points. As far as I have seen, the function Translate doesn´t work with Point3d, it only works with the class Point, which is defined by a Location which is established by the function get and there comes the whole mess!
I am attaching the code I tried (which definitely doesn´t work) in case somebody can give me a hand :-)
private void RunScript(List<Point3d> origin, List<Point3d> destination, ref object vectors, ref object points)
{
List<Vector3d> vec = new List<Vector3d>();
List<Rhino.Geometry.Point> pts = new List<Rhino.Geometry.Point>();
for (int i = 0; i < origin.Count - 2; i++)
{
Vector3d vector = new Vector3d((destination[i].X - origin[i + 1].X), (destination[i].Y - origin[i + 1].Y), (destination[i].Z - origin[i + 1].Z));
//Rhino.Geometry.Point punto = new Rhino.Geometry.Point(origin[i].X, origin[i].Y, origin[i].Z); // this doesn´t work, has to be defined by a location
//Location localizacion = new Location(origin[i]);
//Rhino.Geometry.Point punto = new Rhino.Geometry.Point(localizacion); //wrong again!
if(origin[i + 1].Translate(vector)) //Point3d doesn´t work with Translate
{
pts.Add(origin[i + 1]);
}
vec.Add(vector);
}
points = pts;
vectors = vec;
}
Thanks in advance
Cheers!
Tags:
List<Vector3d> vec = new List<Vector3d>();
List<Point3d> pts = new List<Point3d>();
for (int i = 0; i < origin.Count - 1; i++)
{
Vector3d vector = destination[i] - origin[i + 1];
pts.Add(origin[i + 1] + vector);
vec.Add(vector);
}
points = pts;
vectors = vec;
A = new Rhino.Geometry.Point(new Point3d(5,6,7));
Rhino.Geometry.Point p;
p = new Rhino.Geometry.Point(new Point3d(5,6,7));
// later...
p.Location = new Point3d(12, 12, 12);
// or, alternatively, as Point has a translate method
p.Translate(new Vector3d(7, 6, 5));
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by