Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE POST THE FUNCTION WITH CODE PLEASE DO NOT GIVE THE DIRECTIONS OR GUIDE ON HOW TO DO IT. THANK YOU Problem Statement: Create a
PLEASE POST THE FUNCTION WITH CODE PLEASE DO NOT GIVE THE "DIRECTIONS" OR "GUIDE" ON HOW TO DO IT. THANK YOU
Problem Statement: Create a function named tc1ip that determines the intersection of a line (solution of a given linear equation) with a clipping triangle T. having vertices (0,0),(1,0) and (0,1). The function declaration should have the form function [count, 1ist] = tclip(a,b,c) where the line in question is ordinarily the solution set of the linear equation ax +by=c. The value of the variable count returned should be - 2 if the equation ax+by=c has no solutions (e.g. 0x+0y=1). - 1 if the equation ax+by=c is solved by all values of x and y(0x+0y=0). - 0 if the solutions of ax+by=c do not intersect T (e.g. 0x+1y=7 ), - 1 if the solutions of ax+by=c intersect T in one point (e.g.1x+1y=0), - 2 if the solutions of ax+by=c intersect T in more than one point (e.g.1x1y=0). The variable 1ist, which reports the distinct endpoints of the intersection, should be a - 20 empty array (empty list of 2 -vectors) if count is 2, 1 or 0 , - 21 array (a single column vector)-the unique point of intersection-if count is 1 , - 22 array (list of two column vectors)-the endpoints of the intersection- if count is 2. function [count, list] = tclip(a,b,c) The function tclip analyzes the intersection of the solutions set of axtby=c with the "solid" triangle with vertices (,),(,1),(1,). The return value count is 2 if the solution set of ax+by=c is enpty, -1 if the solution set of ax+by=c is the plane, e if the line fails to intersect the triangle, 1 if the line intersects the triangle in one point, 2 if the line intersects the triangle in infinitely nany points. The return value 1 ist is an enpty 1 ist of 2 -conponent column vectors if counts = a 2 -conponent column vector with the coordinates of intersection If count ==1, a 22 array (1ist of two 2 -conponent column vectors) with the endpoints of the intersection if count==2 count=;1ist=zeros(2,);xdefaultreturnvaluexdefaultreturnvalue(emptylist) if a==0 &8b==0 X CASE = solution set not a line if c=0 x solution set is the plane count =1; x solution set is empty end count =2; return end count=1; list =[0;1]; end end return end If a=0 \& & b=e CASE 2: vertical line x Insert code needed to handle the case of a vertical line return end if ab==08&a=0x CASE 3: line para1lel to hypotenuse x Insert code needed to handle the case of a line parallel to the hypotenuse return end if a=0&&b=0&&ab=0x CASE 4: generic line x check intersection with the y-axis (x=0) y=c/b If
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started