Rhino.Geometry.Point3d start = new Rhino.Geometry.Point3d(0, 0, 0);
Rhino.Geometry.Point3d end = new Rhino.Geometry.Point3d(0, 500, 0 );
Rhino.Geometry.Point3d Center = new Rhino.Geometry.Point3d(-106, 250, 0);
Rhino.Geometry.Arc arc = new Rhino.Geometry.Arc(start, Center, end);
doc.Objects.AddArc(arc);
On the right side it’s good, on the left side there should have been an arc like red line,
and the all original points is on 0 Z position, this arc have some diferent Z point.
this is my code:
Rhino.Geometry.Point3d start = new Rhino.Geometry.Point3d(origemX, origemY,
origemY);
Rhino.Geometry.Point3d end = new Rhino.Geometry.Point3d(X, Y, Z );
Rhino.Geometry.Point3d Center = new Rhino.Geometry.Point3d(I, J, K);
var xaxis = start - Center;
var radius = xaxis.Length;
xaxis.Unitize();
var yaxis = Rhino.Geometry.Vector3d.CrossProduct(Rhino.Geometry.Vector3d.ZAxis,
xaxis);
yaxis.Unitize();
Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(Center, xaxis, yaxis);
var dir = end - Center;
dir.Unitize();
var dot = Rhino.RhinoMath.Clamp(xaxis * dir, -1.0, 1.0);
var angle = System.Math.Acos(dot);
Rhino.Geometry.Plane yplane = new Rhino.Geometry.Plane(plane.Origin, plane.YAxis);
var dist = yplane.ValueAt(end);
if (dist < 0.0)
angle = (System.Math.PI * 2.0) - angle;
Rhino.Geometry.Arc arc = new Rhino.Geometry.Arc(plane, radius, angle);
doc.Objects.AddPoint(start);
doc.Objects.AddPoint(Center);
doc.Objects.AddPoint(end);
private void RunScript(Point3d start, Point3d center, Point3d end, ref object A)
{
// Center must be restricted to the mediatrix of the start-end segment.
// Otherwise it cannot be the center of an arc defined by its two ends.
Plane plane = new Plane(start, end, center);
Line ln = new Line((start + end) / 2, plane.YAxis, 1);
center = ln.ClosestPoint(center, false);
Vector3d vs = start - center;
Vector3d ve = end - center;
Vector3d nor = Vector3d.CrossProduct(vs, ve);
Vector3d tan = Vector3d.CrossProduct(nor, vs);
A = new Arc(start, tan, end);
}
Thanks, I have mistake on start point , I have:
Rhino.Geometry.Point3d start = new Rhino.Geometry.Point3d(origemX, origemY, origemY);
Is supose:
Rhino.Geometry.Point3d start = new Rhino.Geometry.Point3d(origemX, origemY, origemZ);