public void Rotate(AcadGeo.Vector3d vec) { AcadGeo.Vector3d axe = vec.CrossProduct(normal_vector); axe = axe.GetNormal(); if (axe.IsEqualTo(new AcadGeo.Vector3d(0.0, 0.0, 0.0))) { return; } double angle = normal_vector.GetAngleTo(vec, axe); if (angle > AcadFuncs.kPI) { angle -= AcadFuncs.kPI; } if (angle > AcadFuncs.kPI * 0.5) { angle -= AcadFuncs.kPI; } AcadGeo.Tolerance tol = new AcadGeo.Tolerance(0.01, 0.01); if (!up_vector.IsParallelTo(axe, tol)) { up_vector = up_vector.RotateBy(angle, axe); } if (!normal_vector.IsParallelTo(axe, tol)) { normal_vector = normal_vector.RotateBy(angle, axe); } }
internal static Movement4 getMoveVector(Triangle tri, Triangle adjacentTri, Edge commonEdge) { Movement4 r = new Movement4(); Point center = tri.Center; Edge e = center.PerpendicularOn(commonEdge.ToLine()); if (adjacentTri == null) { return(r); } Edge e2 = adjacentTri.Center.PerpendicularOn(commonEdge.ToLine()); Autodesk.AutoCAD.Geometry.Vector3d v = MyConvert.toVector(e); Autodesk.AutoCAD.Geometry.Vector3d v2 = MyConvert.toVector(e2); Autodesk.AutoCAD.Geometry.Vector3d crossv = v.CrossProduct(v2); Autodesk.AutoCAD.Geometry.Vector3d movev = crossv.CrossProduct(v); double angle = v.GetAngleTo(v2); if (angle < 0) { throw new System.Exception("angle<0"); } if (angle > Math.PI) { angle = Math.PI * 2 - angle; } double length = e.Length; Autodesk.AutoCAD.Geometry.Vector3d unitV = movev.GetNormal(); r.move = -unitV * (Math.PI - angle) * 1 / 16; r.dis = length; return(r); }
private AcadGeo.Point3d CalculateCenter() { //AcadGeo.Vector3d vec = AcadFuncs.GetVec( // CalculateBranchPos(position, branch_positions[0], radius, angle), // CalculateBranchPos(position, branch_positions[1], radius, angle)); //AcadGeo.Point3d pos = position + AcadFuncs.GetVec(branch_positions[0], position) * (radius / Math.Sin(angle * 0.5)); //AcadGeo.Plane plane = new AcadGeo.Plane(pos, NormalVec().CrossProduct(vec)); //return position.Mirror(plane); AcadGeo.Vector3d vec1 = AcadFuncs.GetVec(branch_positions[0], position); AcadGeo.Vector3d vec2 = AcadFuncs.GetVec(branch_positions[1], position); AcadGeo.Vector3d tmp_vec = new AcadGeo.Vector3d( vec1.X + vec2.X, vec1.Y + vec2.Y, vec1.Z + vec2.Z); tmp_vec = tmp_vec.GetNormal(); return(position + tmp_vec * (radius / Math.Sin(angle * 0.5))); }