Muutke küpsiste eelistusi

Geometry for Programmers [Kõva köide]

  • Formaat: Hardback, 425 pages, kõrgus x laius x paksus: 234x186x22 mm, kaal: 740 g
  • Ilmumisaeg: 22-Aug-2023
  • Kirjastus: Manning Publications
  • ISBN-10: 1633439607
  • ISBN-13: 9781633439603
  • Formaat: Hardback, 425 pages, kõrgus x laius x paksus: 234x186x22 mm, kaal: 740 g
  • Ilmumisaeg: 22-Aug-2023
  • Kirjastus: Manning Publications
  • ISBN-10: 1633439607
  • ISBN-13: 9781633439603
Master the geometry behind CAD, game engines, GIS, and more! Geometry for Programmers is a hands-on book teaching you the maths behind the tools and libraries to create simulations, 3D prints, and other models in the physical world.

Ideal for developers writing code using CAD libraries, game engines, or rendering tools, the textbook guides you through the math behind graphics and modelling tools using relevant examples and clear explanations that don't require advanced mathematical knowledge. You will learn how mastering manual geometry can help you avoid code layering and repetition and even how to drive down cloud hosting costs by creating more efficient application runtimes.

Key features include:





Speak the language of applied geometry Compose geometric transformations economically Craft custom splines for efficient curves and surface generation Pick and implement the right geometric transformations Confidently use important algorithms that operate on triangle meshes, distance functions, and voxels

Filled with charts, illustrations, and complex equations rendered as simple Python code, this book unlocks geometry in a way you can apply it to your daily work.

About the technology Geometry is the core of game engines, computer-aided design, image-processing libraries, GIS, and much more. Understanding the mathematical underpinnings of tools and libraries empowers you to develop more efficient programming strategies. This unique guide gives you control over the geometry you need to deliver faster, cleaner results and even build your own geometry tools!

Arvustused

"A one of a kind book, brilliant in every way." Maxim Volgin

"Good books teach. The best books produce a change on the reader. This is one of those books." Jose San Leandro

"A great help, not just to anyone wanting to make computer graphics but also anyone who needs to learn linear algebra or calculus, especially linear algebra." Patrick Regan

"Have you ever wondered how game programmers, animated film designers, and car manufacturers model visual aspects of reality? This book shows you how." Ranjit Sahai

Preface xiii
Acknowledgments xv
About this book xvii
About the author xxi
About the cover illustration xxii
1 Getting started
1(13)
1.1 Which parts of programming require geometry?
3(1)
1.2 What is geometry for programmers?
4(1)
1.3 Why not let my tools take care of geometry?
5(1)
1.4 Applied geometry has been around forever; why learn it now?
6(2)
1.5 You don't have to know much to start
8(1)
1.6 SymPy will do your math for you
9(5)
2 Terminology and jargon
14(34)
2.1 Numbers, points, and vectors
15(9)
Numbers
15(6)
Vectors
21(3)
Section 2.1 Summary
24(1)
2.2 Vertices and triangles
24(5)
Being pedantic about triangles
25(1)
Triangle quality
25(3)
Section 2.2 Summary
28(1)
2.3 Lines, planes, and their equations
29(5)
Lines and planes
29(2)
The parametric form for 3D lines
31(3)
Section 2.3 Summary
34(1)
2.4 Functions and geometric transformations
34(7)
What is a function
34(4)
Function types most commonly used in geometric modeling
38(3)
Section 2.4 Summary
41(1)
2.5 The shortest possible introduction to matrix algebra
41(5)
What is algebra'?
41(2)
How does matrix algebra work?
43(2)
Section 2.5 Summary
45(1)
2.6 Exercises
46(1)
2.7 Solutions to exercises
46(2)
3 The geometry of linear equations
48(38)
3.1 Linear equations as lines and planes
49(4)
Introducing a hyperplane
49(2)
A solution is where hyperplanes intersect
51(2)
Section 3.1 Summary
53(1)
3.2 Overspecified and underspecified systems
53(2)
Overspecified systems
53(2)
Underspecified systems
55(1)
Section 3.2 Summary
55(1)
3.3 A visual example of an interactive linear solver
55(5)
The basic principle of iteration
56(3)
Starting point and exit conditions 57' Convergence and stability
59(1)
Section 3.3 Summary
60(1)
3.4 Direct solver
60(5)
Turning an iterative solver into a direct one
60(2)
Algorithm complexity
62(3)
Section 3.4 Summary
65(1)
3.5 Linear equations system as matrix multiplication
65(4)
Matrix equations
65(1)
What types of matrices we should know about
66(2)
Things we're allowed to do with equations
68(1)
Section 3.5 Summary
69(1)
3.6 Solving linear systems with Gaussian elimination and LU-decomposition
69(5)
An example of Gaussian elimination
69(3)
What do "elimination" and "decomposition" mean?
72(2)
Section 3.6 Summary
74(1)
3.7 Which solver fits my problem best?
74(3)
When to use an elimination-based one
74(1)
When to use an iterative one
75(1)
When to use neither
76(1)
Section 3.7 Summary
76(1)
3.8 Practical example: Does a ray hit a triangle?
77(6)
The ray-triangle intersection problem
77(1)
Forming a system
78(2)
Making the equations into code
80(2)
Section 3.8 Summary
82(1)
3.9 Exercises
83(1)
3.10 Solutions to exercises
84(2)
4 Projective geometric transformations
86(40)
4.1 Some special cases of geometric transformations
87(7)
Translation
87(1)
Scaling
88(2)
Rotation
90(4)
Section 4.1 Summary
94(1)
4.2 Generalizations
94(9)
Linear transformations in Euclidean space
94(4)
Bundling rotation, scaling, and translation in a single affine transformation
98(2)
Generalizing affine transformations to projective transformations
100(2)
An alternative to projective transformations
102(1)
Section 4.2 Summary
103(1)
4.3 Projective space and homogeneous coordinates
103(13)
Expanding the whole space with homogeneous coordinates
104(4)
Making all the transformations a single matrix multiplication: Why?
108(8)
Section 4.3 Summary
116(1)
4.4 Practical examples
116(7)
Scanning with a phone
116(4)
Does a point belong to a triangle?
120(2)
Section 4.4 Summary
122(1)
4.5 Exercises
123(1)
4.6 Solutions to exercises
124(2)
5 The geometry of calculus
126(31)
5.1 What is a derivative?
127(9)
Derivative at Apoint
128(1)
Derivative as a function
129(5)
Rules of differentiation
134(1)
Using SymPy to do differentiation
135(1)
Section 5.1 Summary
136(1)
5.2 Smooth piecewise parametric curves
136(7)
Piecewise functions
137(1)
Smooth parametric curves
138(2)
Curvature
140(3)
Section 5.2 Summary
143(1)
5.3 Practical example: Crafting a curve out of lines and circles
143(11)
The biarc building block
143(5)
The line segment and arc building block
148(4)
The combination of both
152(1)
Section 5.3 Summary
153(1)
5.4 Exercises
154(1)
5.5 Solutions to exercises
154(3)
6 Polynomial approximation and interpolation
157(46)
6.1 What are polynomials?
158(7)
Axis intersections and roots of polynomial equations
159(3)
Polynomial derivatives
162(3)
Section 6.1 Summary
165(1)
6.2 Polynomial approximation
165(14)
Maclaurin and Taylor series
166(5)
The method of least squares
171(4)
Practical example: Showing a trend with approximation
175(4)
Section 6.2 Summary
179(1)
6.3 Polynomial interpolation
179(16)
Using Vandermonde matrix to get the interpolating polynomial
180(5)
What limits polynomial interpolation application to small data only?
185(1)
How to lessen unwanted oscillations
186(1)
Lagrange interpolation: Simple, genius, unnecessary
187(4)
Practical example: Showing the trend with interpolation
191(4)
Section 6.3 Summary
195(1)
6.4 Practical example: Showing a trend with both approximation and interpolation
195(5)
The problem
195(2)
The solution
197(2)
Section 6.4 Summary
199(1)
6.5 Exercises
200(1)
6.6 Solutions to exercises
200(3)
7 Splines
203(38)
7.1 Going beyond the interpolation
204(11)
Making polynomial graphs with tangent constraints
204(2)
Practical example: Approximating the sine function for a space simulator game
206(8)
Unexpected fact: Explicit polynomial modeling generalizes power series
214(1)
Section 7.1 Summary
215(1)
7.2 Understanding polynomial splines and Bezier curves
215(18)
Explicit polynomial parametric curves
216(5)
Practical example: Crafting a spline for points that aren't there yet
221(5)
Bezier curves
226(7)
Section 7.2 Summary
233(1)
7.3 Understanding NURBS
233(6)
BS stands for "basis spline"
233(2)
NU stands for "nonuniform"
235(1)
R stands for "rational"
235(1)
Not-so-practical example: Building a circle with NURBS
236(2)
Section 7.3 Summary
238(1)
7.4 Exercises
239(1)
7.5 Solutions to exercises
239(2)
8 Nonlinear transformations and surfaces
241(39)
8.1 Polynomial transformations in multidimensional space
242(13)
The straightforward approach to polynomial transformations
242(5)
The fast and simple approach to polynomial transformations
247(4)
Practical example: Adding the "unbending" feature to the scanning app
251(4)
Section 8.1 Summary
255(1)
8.2 3D surface modeling
255(8)
A surface is just a 3D transformation of a plane
255(2)
Practical example: Planting polynomial mushrooms
257(6)
Section 8.2 Summary
263(1)
8.3 Using nonpolynomial spatial interpolation in geometry
263(14)
Inverse distance interpolation
264(4)
Inverse distance interpolation in space
268(2)
Practical example: Using localized inverse distance method to make a bitmap continuous and smooth
270(5)
Practical example: Building a deformation field with multivariable interpolation to generate better mushrooms
275(2)
Section 8.3 Summary
277(1)
8.4 Exercises
277(1)
8.5 Solutions to exercises
278(2)
9 The geometry of vector algebra
280(30)
9.1 Vector addition and scalar multiplication as transformations
281(1)
9.2 Dot product: Projection and angle
282(8)
Other names and motivations behind them
282(3)
Vectors and their dot product in SymPy
285(1)
Practical example: Using a dot product to light a scene
286(4)
Section 9.2 Summary
290(1)
9.3 Cross product: Normal vector and the parallelogram area
290(7)
Other names and motivations behind them
290(3)
The cross product in SymPy
293(1)
Practical example: Check whether a triangle contains a point in 2D
293(4)
Section 9.3 Summary
297(1)
9.4 Triple product: The parallelepiped volume
297(5)
The geometric sense of the triple product
298(1)
The triple product in SymPy
299(1)
Practical example: Distance to a plane
300(1)
Section 9.4 Summary
301(1)
9.5 Generalization for parallelotopes
302(6)
The meaning
302(1)
The math
302(3)
The code
305(2)
Section 9.5 Summary
307(1)
9.6 Exercises
308(1)
9.7 Solutions to exercises
308(2)
20 Modeling shapes with signed distance junctions and surrogates
310(31)
10.1 What's an SDF?
311(10)
Does it have to be an SDF?
312(1)
How to program SDFs?
313(3)
Theoretical example: Making an SDF of a triangle mesh
316(2)
Practical example: Making an SDF of a rectangle in 2D
318(3)
Section 10.1 Summary
321(1)
10.2 How to work with SDFs
321(7)
How to translate, rotate, or scale an SDF
322(1)
How to unite, intersect, and subtract SDFs
323(3)
How to dilate and erode an SDF
326(1)
How to hollow an SDF
327(1)
Section 10.2 Summary
328(1)
10.3 Some techniques of not-really-SDF implicit modeling
328(13)
Tri-periodic minimal surfaces
329(2)
Practical example: A gyroid with variable thickness
331(1)
Metaballs
332(2)
Practical example: Localizing the metaballs for speed and better governance
334(2)
Multifocal lemniscates
336(1)
Practical example: A play button made of a multifocal lemniscate
337(2)
Section 10.3 Summary
339(1)
10.4 Exercises
339(1)
10.5 Solutions to exercises
339(2)
11 Modeling surfaces with boundary representations and triangle meshes
341(33)
11.1 Smooth curves and surfaces
343(3)
Data representation
343(1)
Operations are also data
344(2)
Section 11.1 Summary
346(1)
11.2 Segments and triangles
346(6)
Vertices and triangles vs. the half-edge representation
347(2)
Pros and cons of triangle meshes
349(3)
Section 11.2 Summary
352(1)
11.3 Practical example: Contouring with marching cubes and dual contouring algorithms
352(13)
Marching cubes
354(6)
Dual contouring
360(3)
Is it that simple in practice, too?
363(1)
Section 11.3 Summary
364(1)
11.4 Practical example: Smooth contouring
365(6)
The algorithm
366(2)
The implementation
368(3)
Section 11.4 Summary
371(1)
11.5 Exercises
371(1)
11.6 Solutions to exercises
372(2)
12 Modeling bodies with images and voxels
374(32)
12.1 How does computed tomography work?
375(3)
12.2 Segmentation by a threshold
378(2)
12.3 Typical operations on 3D images: Dilation, erosion, cavity fill, and Boolean
380(8)
Dilation
381(2)
Erosion
383(1)
Practical example: Denoising
384(2)
Boolean operations on voxel models
386(1)
A few other uses of dilation and erosion
387(1)
Section 12.3 Summary
388(1)
12.4 Practical example: Image vectorization
388(14)
Input image
389(2)
Step 1 Obtain a contour
391(1)
Step 2 Fit the contour
392(1)
Step 3 Make the contour smooth
393(2)
Implementation
395(6)
Section 12.4 Summary
401(1)
12.5 How voxels, triangles, parametric surfaces, and SDFs work together
402(2)
12.6 Exercises
404(1)
12.7 Solutions to exercises
404(2)
Appendix Sources, references, and further reading 406(3)
Index 409
About the author Oleksandr Kaleniuk is the creator of Words and Buttons Online, a collection of interactive tutorials on maths and programming. He works for Materialise as a senior software engineer specialising in geometric algorithms.