Grasshopper

algorithmic modeling for Rhino

hi,

my problem is that i have a set of points in a 3D array, which i want to translate by a given vector. and then i want to continue using these new points that i just moved in the same array. however after the following command, i cannot reach the new point instances.

newP.Transform(Transform.Translation(vect));

i hope i was claer in explaining the problem.

cheers.

Views: 720

Replies to This Discussion

Hi Ipek,

You can do it this way:

for(int i = 0; i < pList.Count; i++){
Point3d newP = new Point3d(pList[i]);
newP.Transform(Transform.Translation(vect));
x[i] = newP;
}

 

or like in the following example:

 

for(int i = 0; i < pList.Count; i++){
pList[i] += vect;
}

 

since points and vectors can easily be manipulated by ordinary math operators i'd recommend this cause it's less code and probably a lot faster in performance.

Altough with other geometry you have to use the Transform method above.

 

i hope it was the right answer to your problem

Cheers FF

hi Florian,

thanks for your reply. i did something similar. i created a new point based on the existing point plus the vector. then i point the initial variable name to the new point. 

Point3d thisP = ptsArray[i, j, k];
Vector3d vect = new Vector3d(thisP - attractor);

Point3d newP = new Point3d(thisP.X + vect.X, thisP.Y + vect.Y, thisP.Z + vect.Z);
ptsArray[i, j, k] = newP;

but i am quite surprised to see that the translate operation does not create a new instance. though this worked well too, so :)

cheers,

ipek

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service