And how did those numbers get so precise up to four decimals digits?.How did the author know that $3.982$ is the leading coefficient to use?.Why does this weird-looking equation pop out from nowhere?.These are basically pictures and animations created in Desmos primarily through the clever use of equations and inequalities - among other features such as tables, animating sliders and regression models. Indeed, if you go to this official staff pick page, you should see that a whole bunch of creative artworks were already being created - anything from cartoon characters, landscape to logos and portraits.īut here’s a problem: when you reach a Desmos artwork page, you get to see the end-result with all the equations and inequalities, without necessarily having any clue about how the sketching process comes about from the beginning to the end: We have also developed the Interpolate helper method, a way to efficiently compute values of a linear function.If you’re of the type who enjoys playing around with graphing calculator, then you might be interested in the so-called Desmos Art. Using the only tool we have, PutPixel, we’ve developed an algorithm that can draw straight line segments on the canvas. In this chapter, we’ve taken the first steps to building a rasterizer. Second, it gave us the Interpolate function, which we will use extensively in the rest of this book. First, it is easier to understand, which is an overriding principle in this book. The reason to present this algorithm is twofold. It might come as a surprise that this line algorithm is not the best or the fastest there is that distinction probably belongs to Bresenham’s Algorithm. DRAW A VERTICAL LINE IN MATH ILLUSTRATIONS CODEWhile this version isn’t much shorter than the previous one, it cleanly separates the computation of the intermediate values of \(y\) and \(x\) from the decision of which is the independent variable and from the pixel-drawing code itself. Figure 6-5: The refactored algorithm handles all cases correctly. This DrawLine can handle all cases correctly (Figure 6-5). \[y = y_0 Listing 6-2: A version of DrawLine that uses Interpolate We can now plug this expression for \(t\) into the second equation: Let’s take the first equation and solve for \(t\): We can decompose this equation into two, one for each coordinate: Any point \(P\) on the line can be obtained by starting at \(P_0\) and moving some distance along the direction from \(P_0\) to \(P_1\): Let’s start by representing a line with parametric coordinates, just as we did with rays before (in fact, you can think of “rays” as lines in 3D). How can we draw the straight line segment between \(P_0\) and \(P_1\)? Suppose we have two canvas points, \(P_0\) and \(P_1\), with coordinates \((x_0, y_0)\) and \((x_1, y_1)\) respectively. DRAW A VERTICAL LINE IN MATH ILLUSTRATIONS HOW TOLet’s explore how to draw the simplest possible element on the canvas: a line between two points. We’ll start from scratch again: we have a canvas of dimensions \(C_w\) and \(C_h\), and we can set the color of individual pixels with PutPixel(), but nothing else. Later, we’ll explore how to use these fast algorithms to achieve results with a quality comparable to that of a raytracer. It turns out we can develop algorithms that answer this new question much faster than raytracing could, as long as we’re willing to make some accuracy trade-offs. For every pixel of the canvas, we answer the question, “Which object of the scene is visible here?” Now we’ll follow an approach that is, in some sense, the opposite: for every object in the scene, we’ll try to answer the question “In which parts of the canvas will this object be visible?” Our raytracer starts from the camera and explores the scene through the viewport. In this part of the book, we’ll explore an entirely different set of algorithms that favor performance over mathematical purity. While non-real-time performance is fine for certain applications, such as architectural visualization or visual effects for movies, it’s not enough for other applications, such as video games. This simplicity comes at a cost: performance. In Part I of this book, we studied raytracing extensively and developed a raytracer that could render our test scene with accurate lighting, material properties, shadows, and reflection using relatively simple algorithms and math.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |