private static void MovePointHandleByRotationSteps(GenericPosture posture, CalibrationHelper calibrationHelper, int handle, PointF point, GenericPostureConstraintRotationSteps constraint) { if (constraint == null) { return; } PointF parent = posture.PointList[constraint.Origin]; PointF leg1 = posture.PointList[constraint.Leg1]; if (parent == leg1 || constraint.Step == 0) { return; } PointF candidate = point; if (constraint.KeepDistance) { PointF leg2 = posture.PointList[posture.Handles[handle].Reference]; float distance = GeometryHelper.GetDistance(parent, leg2); candidate = GeometryHelper.GetPointAtDistance(parent, point, distance); } int constraintAngleSubdivisions = 360 / constraint.Step; posture.PointList[posture.Handles[handle].Reference] = GeometryHelper.GetPointAtClosestRotationStep(parent, leg1, candidate, constraintAngleSubdivisions); }
private static void MovePointHandleAtDistance(GenericPosture posture, int handle, PointF point, GenericPostureConstraintDistanceToPoint constraint, Keys modifiers) { if (constraint == null) { MovePointHandleFreely(posture, handle, point); return; } PointF parent = posture.PointList[constraint.RefPoint]; PointF child = posture.PointList[posture.Handles[handle].Reference]; float distance = GeometryHelper.GetDistance(parent, child); PointF temp = GeometryHelper.GetPointAtDistance(parent, point, distance); int constraintAngleSubdivisions = 8; // (Constraint by 45° steps). if ((modifiers & Keys.Shift) == Keys.Shift) { posture.PointList[posture.Handles[handle].Reference] = GeometryHelper.GetPointAtClosestRotationStepCardinal(parent, temp, constraintAngleSubdivisions); } else { posture.PointList[posture.Handles[handle].Reference] = temp; } }