Computer Science: An Overview: Global Edition (12th Edition)

Published by Pearson Higher Education
ISBN 10: 1292061162
ISBN 13: 978-1-29206-116-0

Chapter 10 - Computer Graphics - Chapter Review Problems - Page 489: 40

Answer

See the explanation

Work Step by Step

Here's a pseudocode to draw a triangle using the brute force approach: ``` initialize a 2D array of pixels with dimensions (width, height) initialize vertices of the triangle: (0,0), (2,2), (2,0) for each pixel in the 2D array: calculate its coordinates (x, y) calculate the distances from the pixel to each vertex of the triangle if the sum of the distances is equal to the distance between two opposite vertices of the triangle: set the pixel to be part of the triangle print the 2D array on the screen ``` This pseudocode iterates through each pixel on the screen, calculates its distance from each vertex of the triangle, and if the sum of the distances is equal to the distance between two opposite vertices, it sets the pixel to be part of the triangle.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.