public static List <Vector2> Generate2DArcBorderPoints(Vector2 arcOrigin, Vector2 arcStartPoint, float degreesFromStart, bool forceShortestArc, int numPoints) { if (numPoints < 2) { return(new List <Vector2>()); } var arcPoints = new List <Vector2>(numPoints); degreesFromStart %= 360.0f; Vector2 toStartPt = (arcStartPoint - arcOrigin); Quaternion rotation = Quaternion.AngleAxis(degreesFromStart, Vector3.forward); float arcRadius = toStartPt.magnitude; toStartPt.Normalize(); if (forceShortestArc) { degreesFromStart = ArcMath.ConvertToSh2DArcAngle(arcOrigin, arcStartPoint, degreesFromStart); } float angleStep = degreesFromStart / (numPoints - 1); for (int ptIndex = 0; ptIndex < numPoints; ++ptIndex) { float angle = ptIndex * angleStep; rotation = Quaternion.AngleAxis(angle, Vector3.forward); Vector2 rotatedAxis = (rotation * toStartPt).normalized; arcPoints.Add(arcOrigin + rotatedAxis * arcRadius); } return(arcPoints); }
public override bool Raycast(Ray ray, out float t) { if (_raycastMode == Shape3DRaycastMode.Solid) { if (_forceShortestArc || AbsDegreeAngleFromStart <= 180.0f) { return(ArcMath.RaycastShArc(ray, out t, _origin, StartPoint, Plane.normal, DegreeAngleFromStart, _epsilon)); } else { return(ArcMath.RaycastLgArc(ray, out t, _origin, StartPoint, Plane.normal, DegreeAngleFromStart, _epsilon)); } } else { if (_forceShortestArc || AbsDegreeAngleFromStart <= 180.0f) { return(ArcMath.RaycastShArcWire(ray, out t, _origin, StartPoint, Plane.normal, DegreeAngleFromStart, _epsilon)); } else { return(ArcMath.RaycastLgArcWire(ray, out t, _origin, StartPoint, Plane.normal, DegreeAngleFromStart, _epsilon)); } } }
public static bool ShArcContains2DPoint(Vector2 point, Vector2 arcOrigin, Vector2 arcStartPoint, float degreesFromStart, ArcEpsilon epsilon = new ArcEpsilon()) { degreesFromStart = ArcMath.ConvertToSh2DArcAngle(arcOrigin, arcStartPoint, degreesFromStart); epsilon.ExtrudeEps = 0.0f; return(ShArcContains3DPoint(point.ToVector3(), false, arcOrigin.ToVector3(), arcStartPoint.ToVector3(), Vector3.forward, degreesFromStart, epsilon)); }
public override bool ContainsPoint(Vector2 point) { if (_forceShortestArc || AbsDegreeAngleFromStart <= 180.0f) { return(ArcMath.ShArcContains2DPoint(point, _origin, _startPoint, _degreeAngleFromStart, _epsilon)); } else { return(ArcMath.LgArcContains2DPoint(point, _origin, _startPoint, _degreeAngleFromStart, _epsilon)); } }
public bool ContainsPoint(Vector3 point, bool checkOnPlane) { if (_forceShortestArc || AbsDegreeAngleFromStart <= 180.0f) { return(ArcMath.ShArcContains3DPoint(point, checkOnPlane, _origin, _startPoint, _plane.normal, _degreeAngleFromStart, _epsilon)); } else { return(ArcMath.LgArcContains3DPoint(point, checkOnPlane, _origin, _startPoint, _plane.normal, _degreeAngleFromStart, _epsilon)); } }