Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following DDA line drawing code: int Image[20][20]; void draw_line(int x1, int y1, int x2, int y2, int value) { // Calculate step size

Consider the following DDA line drawing code:

int Image[20][20]; void draw_line(int x1, int y1, int x2, int y2, int value) {

// Calculate step size double dx = x2 - x1; double dy = y2 - y1;

// Draw points on line double x = x1 + 0.5; for (int y = y1; y <= y2; y++) {

Image[y][(int)x] = value;

x += dx/dy; }

}

a) Trace the draw_line function above to determine which (x,y) locations in the image will be modified when drawing a line from (10,5) to (15,15).

b) How many integer arithmetic operations (+,-,*,/) are needed to draw this line?

c) How many floating point arithmetic operations (+,-,*,/) are needed to draw this line?

d) What would happen with this code if the line we draw has dy = 0?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago