Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Pls show me the script I must create to run the function THANKS!!!!! Given two 2

ID: 3552582 • Letter: P

Question

Pls show me the script I must create to run the function THANKS!!!!!


Given two 2D points, p1 and p2, the parametric line equation is defined as p(t) = (l-t)*p1 + t*p2, for t [0,1], and two 2D points p1 and p2 of the form pi=[xi, yi] Using this equation, write a function to discretize a line between points p1 and p2, based on a given step size Delta t for t and return the computed points. Assume that points holds all computed value pairs in an n x 2 matrix form. function points = discretize Lme(p1, p2, stepsize) Note: Make sure that your function properly handles arbitrary step sizes and discretizes the line in some form from beginning to end, using known or computed information and some common sense. Examples:

Explanation / Answer

function [result] = discretizeLine(p1, p2, stepsize)

if (stepsize<=1 && stepsize>=0)

t=[0:stepsize:1];

t=transpose(t) ;

result=(1-t)*p1+t*p2;

end

if (stepsize>1 || stepsize<0)

result = p1;

%stepsize is out of bound

end

end



Test Run:


points1=discretizeLine([0 0], [1 0], .01)

points1 =

0 0

0.0100 0

0.0200 0

0.0300 0

0.0400 0

0.0500 0

0.0600 0

0.0700 0

0.0800 0

0.0900 0

0.1000 0

0.1100 0

0.1200 0

0.1300 0

0.1400 0

0.1500 0

0.1600 0

0.1700 0

0.1800 0

0.1900 0

0.2000 0

0.2100 0

0.2200 0

0.2300 0

0.2400 0

0.2500 0

0.2600 0

0.2700 0

0.2800 0

0.2900 0

0.3000 0

0.3100 0

0.3200 0

0.3300 0

0.3400 0

0.3500 0

0.3600 0

0.3700 0

0.3800 0

0.3900 0

0.4000 0

0.4100 0

0.4200 0

0.4300 0

0.4400 0

0.4500 0

0.4600 0

0.4700 0

0.4800 0

0.4900 0

0.5000 0

0.5100 0

0.5200 0

0.5300 0

0.5400 0

0.5500 0

0.5600 0

0.5700 0

0.5800 0

0.5900 0

0.6000 0

0.6100 0

0.6200 0

0.6300 0

0.6400 0

0.6500 0

0.6600 0

0.6700 0

0.6800 0

0.6900 0

0.7000 0

0.7100 0

0.7200 0

0.7300 0

0.7400 0

0.7500 0

0.7600 0

0.7700 0

0.7800 0

0.7900 0

0.8000 0

0.8100 0

0.8200 0

0.8300 0

0.8400 0

0.8500 0

0.8600 0

0.8700 0

0.8800 0

0.8900 0

0.9000 0

0.9100 0

0.9200 0

0.9300 0

0.9400 0

0.9500 0

0.9600 0

0.9700 0

0.9800 0

0.9900 0

1.0000 0


points2=discretizeLine([0 0], [1 0], .1)

points2 =

0 0

0.1000 0

0.2000 0

0.3000 0

0.4000 0

0.5000 0

0.6000 0

0.7000 0

0.8000 0

0.9000 0

1.0000 0


points3=discretizeLine([0 0], [1 0], 1.0)

points3 =

0 0

1 0