## Transcribed Text

Problem: Least-Squares Crossing Lines
In this problem, you will be given a set of data that are on the XY plane and a matching set
of data in space. The spatial data also happen to lie on a plane, which is tilted and offset
from the XY plane. The two data sets represent a common configuration: the output of
image-processing where the spatial data have been sensed as the planar data using an X-ray
imaging device. For simplicity, we will model the X-rays as coming from a point source.
The data given to you do not perfectly cross. You must:
(i) Estimate the focus as the point that minimizes line error, and
(ii) Summarize your results
The instructor used a uniform distribution to deviate known planar points from their nominal
positions. You are encouraged to also do this, to gain experience in generating random data
for testing your numerical code. (If you do this, you need to clearly state your methods.) For
example, you can add small random numbers to the X and Y values of PlanarPoints to
study the behavior of your estimator.
The base data, the resulting lines, and the data provided to you with the nearly crossing lines
are given in Figure 1.
(A) (B) (C)
Figure 1: Data to fit to a set of lines. (A) The base data, stars on the X-Y plane and circles
in space. (B) The data fit lines that exactly cross. (b) Randomly deviated data produce lines
that cross imperfectly or not at all.
The data for the assignment is in a file of Matlab code that creates the data for you. If you
execute the Matlab command
a4data
then you will find the variables PlanarPoints and SpatialPoints that are the data.
In your report, clearly and concisely summarize your findings. You may analyze the errors
as the distances from the least-squares focal point to the lines, or the skew-line distance, or
any other reasonable error measure.

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

PlanarPoints = ...

[[0.96; 1.05; 0] [1.00; 8.02; 0] [8.07; 1.99; 0] ...

[7.95; 7.95; 0] [5.00; 2.93; 0]];

SpatialPoints = ...

[[3.75; 3.75; 13.75] [3.60; 6.05; 12.98] [7.14; 2.86; 5.71] ...

[7.73; 7.73; 1.82] [5.00; 4.05; 10.48]];

figure()

for i=1:5

j=3*(i-1);

% line([PlanarPoints(j+1);SpatialPoints(

X(i)=PlanarPoints(j+1);

Y(i)=PlanarPoints(j+2);

Z(i)=PlanarPoints(j+3);

Xsp(i)=SpatialPoints(j+1);

Ysp(i)=SpatialPoints(j+2);

Zsp(i)=SpatialPoints(j+3);

%line([X(i);Xsp(i)],[Y(i);Ysp(i)],[Z(i);Zsp(i)]);

t=0:1:20;

x=X(i)+(Xsp(i)-X(i))*t;

y=Y(i)+(Ysp(i)-Y(i))*t;

z=Z(i)+(Zsp(i)-Z(i))*t;

axis([0 10 0 10 0 25])

%plot3([X(i),Xsp(i)], [Y(i), Ysp(i)], [Z(i), Zsp(i)])

plot3(x,y,z)

hold on

xlabel('x')

ylabel('y')

zlabel('z')

end...