To fit two orthogonal lines we can proceed very similar as in the
the case of the parallel lines. If
is the normal vector
of
the first line, then the second line must have the normal vector
in order to be orthogonal. Therefore again we will
have four unknowns:
,
,
and
.
If the
's are
the points associated with the first line and the
's are
the points associated with the second line, we obtain the following
constrained least squares problem:
subject to
 |
(8.13) |
We only have to change the definition of the matrix
in
mainparallel in order to compute the equations of the two
orthogonal lines. To obtain a nicer plot we also chose different
values for the second set of points.
% mainorthogonal.m
Px = [1:10]'
Py = [ 0.2 1.0 2.6 3.6 4.9 5.3 6.5 7.8 8.0 9.0]'
Qx = [ 0 1 3 5 6 7]'
Qy = [12 8 6 3 3 0]'
A = [ones(size(Px)) zeros(size(Px)) Px Py
zeros(size(Qx)) ones(size(Qx)) Qy -Qx ]
[c, n] = clsq(A,2)
clf; hold on;
axis([-1 11 -1 13])
axis('equal')
plotline(Px,Py,'o',c(1),n,'-')
n2(1) =-n(2); n2(2) = n(1)
plotline(Qx,Qy,'+',c(2),n2,'-')
The Program mainorthogonal computes the two orthogonal lines
Peter Arbenz
2008-09-24