Grasshopper

algorithmic modeling for Rhino

Hello, i try to figure out why in that case i'm not able to rotate a simple control point from another one on a simple 1 span nurbs surface (3deg, order4).
all should work... i'm sure that is a little thing...
any help ?

i have also another question? is there an accurate way for computing the normal vector of a given control point ?


private void RunScript(Surface Srf, int U, int V, int deg, bool swap, ref object A, ref object B, ref object C, ref object D, ref object E)
{
ControlPoint Pt1 = Srf.ToNurbsSurface().Points.GetControlPoint(U, V);
ControlPoint Pt2 = new ControlPoint();
if (swap)
{
Pt2 = Srf.ToNurbsSurface().Points.GetControlPoint(U - 1, V);
}
else
{
Pt2 = Srf.ToNurbsSurface().Points.GetControlPoint(U, V - 1);
}
double u1 = new double();
double v1 = new double();
Plane Fr = new Plane();
Srf.ClosestPoint(new Point3d(Pt2.Location.X, Pt2.Location.Y, Pt2.Location.Z), out u1, out v1);
Srf.FrameAt(u1, v1, out Fr);
Line l1 = new Line(new Point3d(Pt1.Location.X, Pt1.Location.Y, Pt1.Location.Z), new Point3d(Pt2.Location.X, Pt2.Location.Y, Pt2.Location.Z));
Line l2 = new Line(new Point3d(Pt2.Location.X, Pt2.Location.Y, Pt2.Location.Z), Fr.Origin);
Vector3d Ax = Rhino.Geometry.Vector3d.CrossProduct((l1.Direction * -1), (l2.Direction * -1));
Ax.Unitize();
Pt1.Location.Transform(Transform.Rotation(((deg * ( 2 * System.Math.PI)) / 360), Ax, new Point3d(Pt2.Location.X, Pt2.Location.Y, Pt2.Location.Z)));
Srf.ToNurbsSurface().Points.SetControlPoint(U, V, Pt1);
A = Ax;
B = new Point3d(Pt2.Location.X, Pt2.Location.Y, Pt2.Location.Z);
C = Fr;
D = new Point3d(Pt1.Location.X, Pt1.Location.Y, Pt1.Location.Z);
E = Srf;
}

Views: 143

Attachments:

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service