/// <summary> /// Detects parallelism with other geometry points /// </summary> /// <param name = "currentPoint"></param> /// <param name = "initialPosition"></param> /// <returns></returns> public SolverPreviewObject GeometryParallel(Point3D currentPoint, Point3D initialPosition) { var qosLock = QosFactory.Instance.Get(QosNames.ParallelLineLock); qosLock.Begin(); var vec = new gpVec(initialPosition.GpPnt, currentPoint.GpPnt); foreach (var solverGeometricObject in LastGeometry) { if (solverGeometricObject.ParallelAxis.Count == 0) { continue; } foreach (var axis in solverGeometricObject.ParallelAxis) { if (vec.IsParallel(axis.Vector, _precision)) { return(ProjectPointOnDirection(initialPosition, currentPoint, new gpDir(axis.Vector), Color.Black)); } } } qosLock.End(); return(null); }
public override void UpdatePointPosition(int index, Mouse3DPosition vertex) { var firstPoint = Dependency[0].TransformedPoint3D; var secondPoint = Dependency[1].TransformedPoint3D; var thirdPoint = Dependency[2].TransformedPoint3D; if (firstPoint.IsEqual(vertex.Point) || secondPoint.IsEqual(vertex.Point) || thirdPoint.IsEqual(vertex.Point)) { return; } if (firstPoint.IsEqual(new Point3D(0, 0, 0))) { var projectionOnP1P2 = GeomUtils.ProjectPointOnLine(firstPoint, new gpDir(new gpVec(firstPoint.GpPnt, secondPoint.GpPnt)), vertex.Point); if (projectionOnP1P2 != null) { if (projectionOnP1P2.Value.Distance(firstPoint) < Precision.Confusion) { return; } } var projectionOnP2P3 = GeomUtils.ProjectPointOnLine(secondPoint, new gpDir(new gpVec(secondPoint.GpPnt, thirdPoint.GpPnt)), vertex.Point); if (projectionOnP2P3 != null) { if (projectionOnP2P3.Value.Distance(secondPoint) < Precision.Confusion) { return; } } } var vectorV2V1 = new gpVec(secondPoint.GpPnt, firstPoint.GpPnt); var vectorV2V3 = new gpVec(secondPoint.GpPnt, thirdPoint.GpPnt); if (vectorV2V1.IsParallel(vectorV2V3, Precision.Angular)) { return; } var rectangleNormalVector = vectorV2V1.Crossed(vectorV2V3); if (rectangleNormalVector.Magnitude < Precision.Confusion) { return; } switch (index) { case 0: SetFirstPointDraggingHandle(thirdPoint, vertex); break; case 1: SetSecondPointDraggingHandle(vectorV2V1, vertex, secondPoint); break; case 2: SetLeftArrowDraggingHandle(firstPoint, vertex, thirdPoint); break; case 3: SetTopArrowDraggingHandle(thirdPoint, vertex, firstPoint); break; case 4: SetRightArrowDraggingHandle(vertex); break; case 5: SetBottomArrowDraggingHandle(firstPoint, vertex); break; } }