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

Please show me the appropriate script file I must create to execute the function

ID: 3552402 • Letter: P

Question

Please show me the appropriate script file I must create to execute the function! Thank you!


Given two 2D points, p1 and p2, the parametric line equation is defined as p(t) = (l-t)*pi + t*p2 , for t [0,1], and two 2D points pi and P2 of the form p,-=[xi, yi] Using this equation, write a function to discretize a line between points pi and p2, based on a given step size At for t and return the computed points. Assume that points holds all computed value pairs in an n x 2 matrix form. function points = discretizeLine(pl, 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.

Explanation / Answer

function [points] = discretizeLine(p1, p2, stepsize)
dt = stepsize;i=1;
points(i,:) =p1;
while(dt<1 && dt>0)
    i=i+1;
    points(i,:)=(1-dt)*p1+dt*p2;
    dt=dt+stepsize;
end
points(i+1,:) =p2;
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote