Difference between revisions of "Essential Mathematics for Computational Design"

From Design Computation
Jump to: navigation, search
(Vector dot product)
(Vector dot product)
Line 192: Line 192:
  
 
The dot product takes two vectors and produces a number.
 
The dot product takes two vectors and produces a number.
 +
 
For example, if we have the two vectors ​'''a​'''​ and '''​b'''​ so that:  
 
For example, if we have the two vectors ​'''a​'''​ and '''​b'''​ so that:  
 +
 
:'''a​''' = <1, 2, 3>  
 
:'''a​''' = <1, 2, 3>  
 
:'''b'''​ = <5, 6, 7>
 
:'''b'''​ = <5, 6, 7>
  
 
Then the dot product is the sum of multiplying the components as follows:
 
Then the dot product is the sum of multiplying the components as follows:
 +
 
:'''a​''' ​·​ ​​'''b''' = 1​ ​*​ ​5 + 2​ ​*​ ​6 + 3​ ​*​ ​7
 
:'''a​''' ​·​ ​​'''b''' = 1​ ​*​ ​5 + 2​ ​*​ ​6 + 3​ ​*​ ​7
 
:'''a​''' ​·​ ​​'''b''' = 38  
 
:'''a​''' ​·​ ​​'''b''' = 38  
  
In general, given the two vectors ​​'''a'''​ and ​​'''b''':  
+
In general, given the two vectors ​​'''a'''​ and ​​'''b''':
 +
 
 
:'''a​'''​ = <a1, a2, a3>
 
:'''a​'''​ = <a1, a2, a3>
:'''b'''​ = <b1, b2, b3>
+
:'''b'''​ = <b1, b2, b3>
 
:'''a​''' ​·​ ​​'''b'''​ =​ ​a1​ ​*​ ​b1 + a2​ ​*​ ​b2 + a3​ ​*​ ​b3
 
:'''a​''' ​·​ ​​'''b'''​ =​ ​a1​ ​*​ ​b1 + a2​ ​*​ ​b2 + a3​ ​*​ ​b3
  

Revision as of 03:21, 16 December 2021


Essential Mathematics for Computational Design, by Rajaa Issa (Robert McNeel & Associates), introduces to design professionals the foundation mathematical concepts that are necessary for effective development of computational methods for 3-D modeling and computer graphics. This is not meant to be a complete and comprehensive resource, but rather an overview of the basic and most commonly used concepts.

The material is directed towards designers who have little or no background in mathematics beyond high school. All concepts are explained visually using Grasshopper ® (GH), the generative modeling environment for Rhinoceros ® (Rhino).

The content is divided into three chapters. Chapter 1 discusses vector math including vector representation, vector operation, and line and plane equations. Chapter 2 reviews matrix operations and transformations. Chapter 3 includes an in-depth review of parametric curves with special focus on NURBS curves and the concepts of continuity and curvature. It also reviews NURBS surfaces and polysurfaces.

The author would like to acknowledge the excellent and thorough technical review by Dr. Dale Lear of Robert McNeel & Associates. His valuable comments were instrumental in producing this edition. I would also like to acknowledge Ms. Margaret Becker of Robert McNeel & Associates for reviewing the technical writing and formatting the document.


Contents

Vector Mathematics

A vector indicates a quantity, such as velocity or force, that has direction and length. Vectors in 3D coordinate systems are represented with an ordered set of three real numbers and look like:

v = <a1, a2, a3>

Vector representation

In this document, lower case bold letters will notate vectors. Vector components are also enclosed in angle brackets. Upper case letters will notate points. Point coordinates will always be enclosed by parentheses. Using a coordinate system and any set of anchor points in that system, we can represent or visualize these vectors using a line-segment representation. An arrowhead shows the vector direction. For example, if we have a vector that has a direction parallel to the x-axis of a given 3D coordinate system and a length of 5 units, we can write the vector as follows:

v ​= <5, 0, 0>

To represent that vector, we need an anchor point in the coordinate system. For example, all of the arrows in the following figure are equal representations of the same vector despite the fact that they are anchored at different locations.

Figure 1: Vector representation in the 3-D coordinate system.
Given a 3D vector ​v​ = < a1, a2, a3 >, all vector components a1, a2, a3 are real numbers. Also all line segments from a point A(x,y,z) to point B(x+a1, y+a2, z+a3) are equivalent representations of vector ​v​.

So, how do we define the end points of a line segment that represents a given vector? Let us define an anchor point (A) so that:

A = (1, 2, 3)

And a vector:

v ​= <5, 6, 7>

The tip point (B) of the vector is calculated by adding the corresponding components from anchor point and vector ​v​:

B = A + ​v
B = (1+5, 2+6, 3+7)
B = (6, 8, 10)
Figure 2: The relationship between a vector, the vector anchor point, and the point coinciding with the vector tip location.

Position vector

One special vector representation uses the origin point (0,0,0) as the vector anchor point. The position vector ​v ​= <a1,a2,a3> is represented with a line segment between two points, the origin and B, so that:

Origin point = (0,0,0)
B = (a1,a2,a3)
Figure 3: Position vector. The tip point coordinates equal the corresponding vector components.
A position vector for a given vector ​v​= < a1,a2,a3 > is a special line segment representation from the origin point (0,0,0) to point (a1,a2,a3).

Vectors vs. points

Do not confuse vectors and points. They are very different concepts. Vectors, as we mentioned, represent a quantity that has direction and length, while points indicate a location. For example, the North direction is a vector, while the North Pole is a location (point). If we have a vector and a point that have the same components, such as:

v​ = <3,1,0>
P = (3,1,0)

We can draw the vector and the point as follows:

Figure 4: A vector defines a direction and length. A point defines a location.

Vector length

As mentioned before, vectors have length. We will use |​a​| to notate the length of a given vector ​a​. For example:

a ​= <4, 3, 0>
|​a​| = √(4​2​ + 3​2​ + 0​2​)
|​a​| = 5

In general, the ​length​ of a vector ​a​<a1,a2,a3>​ ​is​ ​calculated as follows:

|​a​| = √(a1​2​ + a2​2​ + a3​2​)
Figure 5: Vector length.

Unit vector

A unit vector is a vector with a length equal to one unit. Unit vectors are commonly used to compare the directions of vectors.

A unit vector is a vector whose length is equal to one unit.

To calculate a unit vector, we need to find the length of the given vector, and then divide the vector components by the length. For example:

a ​= <4, 3, 0>
|​a​| = √(4​2​​ + 3​2​ + 0​2​​)
|​a​| = 5 unit length

If ​b​ = unit vector of ​a​, then:

b​ = <4/5, 3/5, 0/5>
b​ = <0.8, 0.6, 0>
|​b​|​ = ​√(0.8​2​ + 0.62​​ + 02​)
|​b​|​ = ​√(0.64 + 0.36 + 0)
|​b​|​ = ​√(1) = 1 unit length

In general:

a ​= <a1, a2, a3>
The unit vector of ​a ​= <a1/|​a​|, a2/|​a​|, a3/|​a​|>
Figure 6: Unit vector equals one-unit length of the vector.

Vector operations

Vector scalar operation

Vector scalar operation involves multiplying a vector by a number. For example:

a ​= <4, 3, 0>
2​*a​ = <2*4, 2*3, 2*0>
2​*a​ = <8, 6, 0>
Figure 7: Vector scalar operation.

In general, given vector ​a ​= <a1, a2, a3>, and a real number ​t

t*a ​= <​ t​*a1, ​t​*a2, ​t​*a3 >

Vector addition

Vector addition takes two vectors and produces a third vector. We add vectors by adding their components.

Vectors are added by adding their components.

For example, if we have two vectors:

a​<1, 2, 0>
b​<4, 1, 3>
a​+​b ​= <1+4, 2+1, 0+3>
a​+​b ​= <5, 3, 3>
Figure 8: Vector addition.

In general, vector addition of the two vectors ​a​ and ​b​ is calculated as follows:

a ​= <a1, a2, a3>
b ​= <b1, b2, b3>
a​+​b ​= <a1+b1, a2+b2, a3+b3>

Vector addition is useful for finding the average direction of two or more vectors. In this case, we usually use same-length vectors. Here is an example that shows the difference between using same-length vectors and different-length vectors on the resulting vector addition:

Figure 9: Adding various length vectors (left). Adding same length vectors (right) to get the average direction.

Input vectors are not likely to be same length. In order to find the average direction, you need to use the unit vector of input vectors. As mentioned before, the unit vector is a vector of that has a length equal to 1.

Vector subtraction

Vector subtraction takes two vectors and produces a third vector. We subtract two vectors by subtracting corresponding components. For example, if we have two vectors​ a​ and ​b​ and we subtract ​b​ from ​a​, then:

a​<1, 2, 0>
b​<4, 1, 4>
a​-​b ​= <1-4, 2-1, 0-4>
a​-​b ​= <-3, 1, -4>

If we subtract ​b​ from ​a​, we get a different result:

b​ ​-​ ​a ​= <4-1, 1-2, 4-0>
b ​-​ ​a ​= <3, -1, 4>

Note that the vector ​b​ ​-​ ​a​ has the same length as the vector a​ -​ b​, but goes in the opposite direction.

Figure 10: Vector subtraction.

In general, if we have two vectors, ​a​ and ​b​, then ​a​ ​-​ ​b​ is a vector that is calculated as follows:

a ​= <a1, a2, a3>
b ​= <b1, b2, b3>
a​ ​-​ ​b ​= <a1​ ​-​ ​b1, a2​ ​-​ ​b2, a3​ ​-​ ​b3>

Vector subtraction is commonly used to find vectors between points. So if we need to find a vector that goes from the tip point of the position vector ​b to the tip point of the position vector ​a​, then we use vector subtraction (​a-b) as shown in Figure 11.

Figure 11: Use vector subtraction to find a vector between two points.

Vector properties

There are eight properties of vectors. If ​a​, ​b​, and ​c​ are vectors, and ​s​ and ​t​ are numbers, then:

a​ ​+​ ​b​ = ​b​​ ​+​ ​a​
a​ ​+​ ​0 = ​a​
s​ ​*​ ​(​a​ ​+​ ​b​​) = ​s​​ ​*​ ​a​​ ​+​ ​s​​ ​*​ ​b
s​ ​*​ ​t​ ​*​ ​(​a​) = ​s​ ​*​ ​(​​t​ ​*​ ​a​​)
a​ ​+​ ​(​b​ ​+​ ​c​) = (​a​​ ​+​ ​b​​)​ ​+​ ​c
a​​ ​+​ ​(-​a​​) = 0
(​s​ + ​t​)​ ​*​ ​a​​ = ​s​​ ​*​ a​​ ​+​ ​t​ ​*​ ​a​
1​ ​*​ ​a​ = ​a​

Vector dot product

The dot product takes two vectors and produces a number.

For example, if we have the two vectors ​a​​ and ​b​ so that:

a​ = <1, 2, 3>
b​ = <5, 6, 7>

Then the dot product is the sum of multiplying the components as follows:

a​ ​·​ ​​b = 1​ ​*​ ​5 + 2​ ​*​ ​6 + 3​ ​*​ ​7
a​ ​·​ ​​b = 38

In general, given the two vectors ​​a​ and ​​b:

a​​ = <a1, a2, a3>
b​ = <b1, b2, b3>
a​ ​·​ ​​b​ =​ ​a1​ ​*​ ​b1 + a2​ ​*​ ​b2 + a3​ ​*​ ​b3

We always get a positive number for the dot product between two vectors when they go in the same general direction. A negative dot product between two vectors means that the two vectors go in the opposite general direction.

Figure 12: When the two vectors go in the same direction (left), the result is a positive dot product. When the two vectors go in the opposite direction (right), the result is a negative dot product.

When calculating the dot product of two unit vectors, the result is always between 1 and +1. For example:

a​​ = <1, 0, 0>
b​ = <0.6, 0.8, 0>
a​​ ​·​ ​b​ = (1​ ​*​ ​0.6, 0​ ​*​ ​0.8, 0​ ​*​ ​0) = 0.6

In addition, the dot product of a vector with itself is equal to that vector’s length to the power of two. For example:

a​​ = <0, 3, 4>
a​​ ​·​ ​a​ ​= 0​ ​*​ ​0​ ​+​ ​3​ ​*​ ​3​ ​+​ ​4​ ​*​ ​4
a​ ​·​ ​a​ ​= 25

Calculating the square length of vector ​a​:

|​ a​ ​| = √(4​2​ ​+​ ​3​2​ ​+​ ​0​2​​)
|​ ​a​ ​| = 5
|​ a​ ​|​2 ​= 25

Vector dot product, lengths, and angles

Dot product properties

Vector cross product

Cross product and angle between vectors

Cross product properties

Vector equation of line

Vector equation of a plane

Tutorials

Face direction

Input

Parameters

Solution

Exploded box

Input

Parameters

Solution

Tangent spheres

Input

Parameters

Solution

Matrices and Transformations

Matrix operations

Matrix multiplication

Method 1

Method 2

Identity matrix

Transformation operations

Translation (move) transformation

Rotation transformation

Scale transformation

Shear transformation

Mirror or reflection transformation

Planar Projection transformation

Tutorial

Multiple transformations

Input

Additional input

Solution

Parametric Curves and Surfaces

Parametric curves

Curve parameter

Curve domain or interval

Curve evaluation

Tangent vector to a curve

Cubic polynomial curves

Evaluating cubic Bézier curves

NURBS curves

Degree

Control points

Weights of control points

Knots

Knots are parameter values

Knot multiplicity

Fully-multiple knots

Uniform knots

Non uniform knots

Evaluation rule

Characteristics of NURBS curves

Clamped vs. periodic NURBS curves

Weights

Evaluating NURBS curves

Solution

Curve geometric continuity

Curve curvature

Parametric surfaces

Surface parameters

Surface domain

Surface evaluation

Tangent plane of a surface

Surface geometric continuity

Surface curvature

Principal curvatures

Gaussian curvature

Mean curvature

NURBS surfaces

Characteristics of NURBS surfaces

Singularity in NURBS surfaces

Trimmed NURBS surfaces

Polysurfaces

Tutorials

Continuity between curves

Input

Parameters

Solution

Surfaces with singularity

Input

Parameters

Solution

References

Edward Angel, "Interactive Computer Graphics with OpenGL,” Addison Wesley Longman, Inc., 2000.

James D Foley, Steven K Feiner, John F Hughes, "Introduction to Computer Graphics" Addison-Wesley Publishing Company, Inc., 1997.

James Stewart, "Calculus," Wadsworth, Inc., 1991.

Kenneth Hoffman, Ray Kunze, “Linear Algebra”, Prentice-Hall, Inc., 1971

Rhinoceros® help document, Robert McNeel and Associates, 2009.