Synopsis:
This book is an introductory textbook on 3D math, geometry and algebra in three-dimensional space. It aims to show you how to use math to describe objects in three dimensions and their positions, orientations, and trajectories. This is not a book about computer graphics, simulation, or even computational geometry, but the reader will certainly need the information here if he or she intends to study these subjects.
This is an appropriate book for video game program developers. While the book assumes that most readers are learning to write video games, we expect a broader audience and have designed the body of the book with a diverse audience in mind. If you are a program developer or interested in learning how to make video games, feel free to join! If you don't meet those criteria, then you can still gain a lot here.
Every effort has been made to make this book useful for designers and technical artists as well. Although there are some code snippets in this book, they are easy to read (hopefully) even for non-program developers. Most importantly, while you need to understand the concepts involved before you can understand the code, the reverse doesn't hold true. We use code examples to illustrate how ideas can be realized on a computer, rather than explaining the ideas themselves.
Chapter 1: Cartesian Coordinate Systems
1.1 One-dimensional mathematics
Natural Number : A set of non-negative integers characterized by order and infinity.
Because of the need for numbers in daily life, natural numbers were created first, which are mentioned here as "the number of dead sheep".
Integer : Integers are composed of natural numbers and their negative counterparts.
Because of the development of production and life, the generation of economic activities, gradually began to have poverty, indebtedness, borrowing and lending needs, and so on, and so on the basis of natural numbers to expand to the whole number.
** Rational numbers: integers and fractions **
By then expanding on the whole numbers, such as having to buy half a sheep, and expanding into the realm of fractions, the number range is expanded from whole numbers to rational numbers.
Real Number : Includes rational and irrational numbers.
Sometimes values are encountered that cannot be accurately represented in real terms, typically such as Π (pi).
What we need to know is that rational numbers are countable (i.e., can correspond one-to-one with natural numbers), but real numbers are uncountable.
The study of natural numbers and integers is calledDiscrete Mathematics
The study of real numbers is calledContinuous Mathematics
The real world is discrete. How does this affect designers of 3D computer-generated virtual reality? By their very nature, computers are discrete and finite, and are more likely to encounter the results of discrete and finite nature in the creative process rather than in the real world.
These numbers can be of type short, int, float and double.
Types of variables used in discrete mathematics in computers:
- short: short is a 16-bit integer that can store 65536 different values.
- int: int is a 32-bit integer that can store up to 4,294,967,296 different values
- float: A float is also a 32-bit value that can storesubset of rational numbers (math.)(Slightly less than 4294967296, where the details don't matter).
- double: double is similar to float, but it uses 64 bits instead of 32.
The first law of computer graphics:
If it looks right, it's right.
1.2 Two-dimensional Cartesian space (flat space)
- Every two-dimensional Cartesian coordinate space has a special location, called the origin, which is the "center" of the coordinate system, with coordinates (0, 0).
- Every two-dimensional Cartesian coordinate space has two lines passing through the origin. Each line is called an axis (Axis) and can extend infinitely in two opposite directions.
- The two axes are perpendicular to each other (actually, they don't necessarily have to be perpendicular, but most common systems we've seen will have vertical axes).
Describes coordinate positions in a two-dimensional coordinate system:
In two dimensions, two numbers can be used to specify a position (in fact, the use of two numbers to describe the position of a point is why it is called two dimensions or two-dimensional space. In three dimensions or three-dimensional space, the use of three numbers is required). In the example of (2,4), the first coordinate (i.e., 2) is called the x-coordinate; the second coordinate (i.e., 4) is called the y-coordinate.
Note that a vertical grid line consists of all points with the same x coordinate; in other words, a vertical grid line (actually any vertical line) marks the line of constant x. Similarly, horizontal grid lines mark lines of constant y. That is, all points on the line have the same y coordinate. When discussing polar coordinate space, this point needs to be recalled a little.
1.3 Three-dimensional Cartesian space
1.3.1 Adding new dimensions and axes
In 3D, we need 3 axes to create a coordinate system. The first two axes are called the x-axis and the y-axis, just like in 2D (of course, it is inaccurate to say that they are the same as the 2D axes, which will be explained in more detail later). We will refer to the third axis (predictably) as the z-axis. In general, we set it up so that all the axes are perpendicular to each other, i.e., each axis is perpendicular to the others.
In three dimensions, any pair of axes defines a plane that contains two axes and is perpendicular to a third. Similarly, the xz plane is perpendicular to the y-axis and the yz plane is perpendicular to the x-axis. We can think of any of these planes as our own two-dimensional Cartesian coordinate space.
1.3.2 Specifying a position in three-dimensional space
In 3D, points are specified using 3 numbers x, y and z. These numbers give signed distances in the yz, xz and xy planes respectively.
The distance will be measured along a straight line parallel to the axis. For example, the x-value is the signed distance to the yz-plane, measured along a line parallel to the x-axis.
1.3.3 Left-handed and right-handed coordinate spaces
All two-dimensional coordinate systems are in some sense "equal.", for any two two-dimensional coordinate spaces A and B, it is possible to rotate coordinate space A so that +x and +y point the same way as they do in coordinate space B (assuming the axes are perpendicular).
The 3D coordinate system has two weeks of coordinate types:
left-handed (Left-Handed) coordinate space and right-handed (Right-Handed) coordinate space.
If two coordinate spaces have the same Handedness, it is possible to rotate them so that the axes are aligned; if the two coordinate spaces have opposite Handedness, then this is not possible.
This is a left-handed coordinate system in three dimensions.
This is a right-handed space coordinate system.
Left- and right-handed coordinate systems also differ in the definition of "positive rotation".
Suppose there is a line in space around which we need to rotate by a specified angle, call this line the axis of rotation. First we must define the direction in which the axis is "pointing", and based on that we can specify the positive direction of rotation.
In the left-handed coordinate system, positive rotation is Clockwise when viewed from the positive end of the axis.
And in the right-handed coordinate system, forward rotation is counterclockwise (Counterclockwise) rotation.
1.4 Some fragmented knowledge
Summation Notation
To obtain the product of a series of values, a similar representation can be used:
interval sign (math.)
Angles, degrees and radians
Degree : 360 degrees for one week
Radian: the length of the segment of the arc for which the degree is measured.
trigonometric function
Use the unit circle to define trigonometric functions:
In 2D, if you start with a unit line pointing at +x and then rotate that line counterclockwise by an angle of 0, you can draw that angle at Standard Position (or rotate the line in the other direction if that angle is negative).
The (x,y) coordinates of the endpoints of the lines thus rotated have special properties and are so mathematically important that they are given special functions called the cosine (cosine) and sine (sine) of the angle, defined as follows.
The definitions of secant, cosecant, tangent and cotangent can be continued on the basis of the sine and cosine functions
Than the relationship, keeping in mind the Hook Theorem: Hook 3 Strand 4 Chord 5
Constant equation between trigonometric functions:
Pythagorean Theorem: (Pythagorean Theorem)
times the angle formula:
The sine and cosine theorems: