Syntax
[PLR,PLL]=PLcirclearc(cp,A,B,[])
Input Parameter
cp : | | center point or radius (+/-) |
A : | | point A or angle w1 |
B : | | point B or angle w2 |
Output Parameter
PLR : | | Right hand arc starting at A (red) |
PLL : | | Left hand arc starting at B (green) |
Examples
PLcirclearc([10 10],[10 11],[9 10])
[PLX,PLY]=PLcirclearc(10,[10 0],[0 0]); cla; PLplot(PLX); shg
[PLX,PLY]=PLcirclearc(-10,[10 0],[0 0]); shg; PLplot(PLY,'g-'); shg
Copyright 2019-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, PLcirclearc
, calculates two circle arcs between two points on a circle, following the right-hand rule. It is part of the SolidGeometry library.
Input Parameters
- cp: Center point of the circle or radius (R) with a sign indicating direction.
- A: Point A on the circle or angle w1.
- B: Point B on the circle or angle w2.
Output Results
- PLR: Right-hand arc starting at A (red).
- PLL: Left-hand arc starting at B (green).
Algorithm Steps
- If
cp
is a scalar, it is treated as the radius (R). The midpoint m
between A and B is calculated, and the vector eab
from A to B is determined.
- The unit vector
e1
is derived from eab
, and o1
is the perpendicular vector to e1
.
- The angle
w
is calculated as half the angle subtended by A and B at the circle's center, and d
is the distance from m
to the center point cp
.
- The center point
cp
is recalculated using m
, d
, and o1
.
- Vectors
e1
and e2
are calculated from cp
to A and B, respectively.
- The radius
R
is determined from the norm of e1
.
- An error is raised if A and B are not equidistant from
cp
.
- Angles
w1
and w2
are calculated using atan2
for vectors e1
and e2
.
- Adjust
w1
and w2
to ensure they are positive and w2
is greater than w1
.
- Calculate the right-hand arc
PLR
using the function PLcircle
with parameters R
, w2-w1
, and w1
, then add cp
.
- Calculate the left-hand arc
PLL
by flipping the result of PLcircle
with parameters R
, w1-w2+2*pi
, and w2
, then add cp
.
- If no output is specified, plot the points and arcs using
SGfigure
and PLplot
, with annotations for PLR
and PLL
.
Algorithm explaination created using ChatGPT on 2025-08-19 08:17. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21