From: Chanpreet on
how to draw an arc between two points given centre and radius on matlab
From: Walter Roberson on
Chanpreet wrote:
> how to draw an arc between two points given centre and radius on matlab

If you are given the two points, and given the centre and radius, then you
cannot always do that. The distance from the centre and each of the points
define radii, and if those two radii are not equal or are not equal to the
given radius, then you cannot draw a circular arc.

The circular arcs that pass through any two given points define a line. If the
centre is not on that line, you cannot do what you ask. Only one coordinate of
the centre would need to be given, and the radius would not be needed. If,
alternately, the radius were given, then that would narrow it to one of
exactly two points, and the only reason the centre would need to be given
would be to distinguish which of the two points it was.

Did you have something different in mind, such as a non-circular arc? Perhaps
a parabolic arc, and the centre is really the focus?


Anyhow...


You can use arctan to find the sector angle to be drawn. Be sure to check in
case you are crossing over the periodic boundary, as you probably want to draw
the smaller of the two arcs. Then, knowing the angles involved, linspace() the
angle range into an appropriate number of points, and then the points of the
arc are

[radius * cos(theta_range) + x of centre, radius * sin(theta_range) + y of
centre)]
From: Roger Stafford on
"Chanpreet " <c.kaur(a)tue.nl> wrote in message <hotir8$8a8$1(a)fred.mathworks.com>...
> how to draw an arc between two points given centre and radius on matlab

Assuming you are in two dimensions, let your two points be the column vectors P1 = [x1;y1], and P2 = [x2;y2], and let the center be P0 = [x0;y0]. Then an arc between P1 and P2 with P0 as its center can be drawn by:

n = 1000; % The number of points in the arc
v1 = P1-P0;
v2 = P2-P0;
c = det([v1,v2]); % "cross product" of v1 and v2
a = linspace(0,atan2(abs(c),dot(v1,v2)),n); % Angle range
v3 = [0,-c;c,0]*v1; % v3 lies in plane of v1 and v2 and is orthog. to v1
v = v1*cos(a)+((norm(v1)/norm(v3))*v3)*sin(a); % Arc, center at (0,0)
plot(v(1,:)+x0,v(2,:)+y0,'y.') % Plot arc, centered at P0
axis equal

Note that it is assumed here that P2 is the same distance from P0 as is P1. If not, the arc will miss P2, though its endpoint will be on the line through P0 and P2.

Roger Stafford
From: Roger Stafford on
> "Chanpreet " <c.kaur(a)tue.nl> wrote in message <hotir8$8a8$1(a)fred.mathworks.com>...
> > how to draw an arc between two points given centre and radius on matlab

I should have added that if you are working with three dimensional space rather than two, a method of generating the arc was given in a thread yesterday at:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/277881

Roger Stafford