Question

In: Computer Science

Write the algorithm in pseudocode for scan-converting (filling in the interior) of an axis-aligned right triangle...

Write the algorithm in pseudocode for scan-converting (filling in the interior) of an axis-aligned right triangle (the base is aligned with the x-axis and the orthogonal leg is aligned with the y-axis).

Solutions

Expert Solution

Answer.

Step 1

Pseudo code:

Declare

           Read x //Base axis

           Read y //Orthogonal leg

         Read color //Color to fill the interior

//Defining scan_converting

Function scan_converting(Triangle T1, Color color)

            //Filling interior based on pixel

            For each pixel P1 at (x,y)

                        If (Inside (T1,P1))

                                    setPixel(x,y,color)

                        End If

            End Loop

End

Step 2

Explanation:

  • The setPixel() fills the interior with the given color.
  • To fill the interior, first one need to find the edges of triangle, the Inside() method finds the edge.
  • The Triangle class is responsible to draw the triangle with the x and y coordinate values.

Kindly upvote please,

Thank you.


Related Solutions

Write pseudocode for quick find algorithm anf quick union algorithm Write pseudocode for quick find algorithm...
Write pseudocode for quick find algorithm anf quick union algorithm Write pseudocode for quick find algorithm and quick union algorithm
write a java program for area and perimeter of right triangle
write a java program for area and perimeter of right triangle
1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any...
1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any positive integer n, it will print out the sum of the squares from 1 to n. For example given 3 the algorithm will print 14 (because 1 + 4 + 9 =14) You can use multiplication denoted as * in your solution and you do not have to define it (For example. 3*3=9) For example if n is 6 it will print: The sum...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the following requirements: Reads in a series of positive integers,  one number at a time;  and Calculate the product (multiplication) of all the integers less than 25,  and Calculate the sum (addition) of all the integers greater than or equal to 25. Use 0 as a sentinel value, which stops the input loop. [ If the input is 0 that means the end of the input list. ]...
Write an algorithm (in pseudocode, with proper indentation for blocks of code in loops or conditional...
Write an algorithm (in pseudocode, with proper indentation for blocks of code in loops or conditional statements) that finds and returns the location of the first negative integer in a sequence of integers.
Write in c++ as simple as possible In a right triangle, the square of the length...
Write in c++ as simple as possible In a right triangle, the square of the length on one side is equal to the sum of the squares of the lengths of the other two sides.  Write a program that prompts the user to enter the length of three sides of the tringle (as doubles) and the outputs a message indication whether the triangle is a right triangle.  You should split this into two functions (but only one .cpp file).  One function is main()...
Write pseudocode to implement the paranoid algorithm. (You vs 2 other players)
Write pseudocode to implement the paranoid algorithm. (You vs 2 other players)
Write class Hypotenuse that calculates the length of the hypotenuse of a right triangle and return...
Write class Hypotenuse that calculates the length of the hypotenuse of a right triangle and return to HypotenuseTest class. The lengths of the other two sides are given by the user by using HypotenuseTest class and send into Hypotenuse class. Hypotenuse class should take two arguments of type double and return the hypotenuse as a double into HypotenuseTest’s Main method. Finally, the HypotenuseTest class displays the hypotenuse side of a triangle.
1a. Write pseudocode for a divide-and-conquer algorithm for finding the po- sition of the largest element...
1a. Write pseudocode for a divide-and-conquer algorithm for finding the po- sition of the largest element in an array of n numbers. 5. Find the order of growth for solutions of the following recurrences. a . T(n)=4T(n/2)+n,T(1)=1 b. T(n)=4T(n/2)+n2,T(1)=1 c. T(n)=4T(n/2)+n3,T(1)=1
Write an algorithm in pseudocode for the binary search method using a while loop (iterative version)...
Write an algorithm in pseudocode for the binary search method using a while loop (iterative version) The recursive ternarySearch method returns true or false depending if the element was found or not. The ternarySearch method works in a similar manner to a binary search except it uses two mid values that “divide” the array into three portions. So, it needs to consider three recursive scenarios: See sample run: Accounts are: [0] 5658845 [1] 8080152 [2] 1005231 [3] 4520125 [4] 4562555...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT