Upload
tracey-rogers
View
215
Download
0
Embed Size (px)
Citation preview
Vectors
• A mathematical entity which has a magnitude and direction. Drawn as an arrow.
• In Latin, it means “carrier”– (Diseases, as in rats were a vector for the black
plague)• A few terms:
head
tailLength, magnitude (a scalar)
Notation
• VectorsV
– Sometimes we’ll refer to the components of a Vector like this:
• Vx Vy Vz – Or like this
• Scalars (float’s)k
V
z
y
x
V
V
V
9.3
6.2
3.17
Another Example
http://w3.shorecrest.org/~lisa_peck/physics/syllabus/mechanics/circularmotion/images_explained.htm
Vector components
• X, Y, and Z (in 3D). Mini-offsets along axes.• Example: The vector (5, 3, -1)
1. Start at "current location"2. Using these axes (RHS)…3. Move 5 units (to the right) along the x axis…4. Move 3 units (up) along the y axis…5. Move 1 units (in – WHY?) along the z axis…6. All together it is as if we moved from the origin this distance/direction.
Recap
• Have a magnitude (the length)• Have a direction (the direction)• Composed of mini-offsets along axes.• No position
– Map: Could be from Lucasville to Minford– Coaster: Could be gravity applied to a plane– B.Balls: Could be a car tapping a guard rail.– But…
…They are related.
• One way:– P: Starting position.– V: A vector indicating a direction of movement.– Q: Ending position.
P
V
Q
• Note: The same vector V is the distance and direction from P to Q AND from A to B.
A
V
B
…They are related
• Another way:• The point P = the head of the Vector P when
the tail is at the origin.
• So…that’s why we’ll use our Vector3 class for both Points and Vectors.– We’ll always interpret a vector as one or the other (but
never both at the same time)
Vector P Point P
Vector properties
• We’ll look at a number of Vector Operations (Chapter 5 in the book)
• Ways of looking at each:– Symbolically: With a symbol.– Numerically:
• The steps to “do” this operation• The way you’ll implement it in Python
– Graphically: With a picture• Usually the most complicated / useful• Often many interpretations.
Zero Vector (5.3)
• A property, not an operation• Just a vector with 3 0’s for its components.• Think of it either as:
– A zero-length vector– A point at the origin.
Vector Negation (5.4)
• Symoblically:• Numerically:
– Negate the 3 components– Define the __neg__ method in Python:
• Should return a new Vector3.
• Graphically:
V
V
V
Vector Length (5.5)
• Symbolically: (NOT absolute value)– This is a scalar value.
• Numerically: – How do we do it in 2D?– Pythagorean Theroem!– It’s the same in 3D – just include the z component.– So…– In python, define a length method (not the same
as __len__)
V
222zyx VVVV
Vector length, an application
• Idea: If we have a vector indicating the distance between 2 points, we can calculate the length to find the distance between the 2 points.
C
K
V
If the length of V < carRad + kittenRad, the kitten eats the tiny car.
Bounding volume in 3D is a sphere, not a circle.
Vector-scalar multiplication (5.6)
• Symbolically: or or • Numerically:
– Just multiply the components by the scalar to get a new vector.
– In python, define the __mul__ method and the __rmul__ method.
• V * 7 # To python, this is V.__mul__(7).• 7 * V # To python, this is 7.__mul__(V). Int’s don’t know how to
handle a Vector3!• 7 * V # If you’ve define it, this is V.__rmul__(7).
– Just call your __mul__ method.
Vk
Vk
* kV *
Vector-scalar multiplication, cont.
• Graphically: V
5.0*V
V2
Note: Multiplication changes the magnitude, not the direction.
OK, multiplying by a negative reverses the direction – it’s really a combination multiplication & negation
Note2: Point multiplication doesn’t really have a meaning.
)5.0*()5.0(* VV
An Example
Suppose you're travelling along the ground at 10 mph: (0,0,10)
You double your speed: Now your velocity is (0,0,20)
Vector-scalar division
• Symbolically: – Note: isn’t allowed
• Numerically:– Really just (or you can divide the
components)– In python, define the __truediv__ method.
• There is a __rtruediv__ method but DON’T define it!
k
V
V
k
kV1*
Vector normalization (5.7)
• A new symbol:– A Unit or normalized vector is written like
• It’s still a vector.
– Unit-length vectors have the property that
• Normalization is the process of “shrinking” or “growing” a vector so that:– It’s direction is unchanged.– It’s length becomes 1.0
V
0.1ˆ V
Vector normalization, cont.
• Any ideas? What operation “grows” / “shrinks” a vector?– Multiplication (or division).
• Suppose we have a vector V.– Q: What do we need to multiply by so that length
becomes 1.0?– A: The length of the vector.
• So:V
VV
ˆ
Vector addition & subtraction (5.8)
• Symbolically:
• Numerically:– Addition: Just add the components to get a new
vector (order is not important)– Subtraction: Subtract the components to get a
new vector (order IS important)• The same as • This is a negation followed by an addition
WV
WV
)( WV
Vector Addition, cont.
• Graphically:– Place the second tail on the first head.– The result goes from the first tail to the last head.
V
W
WV
Vector Addition, Example #1
Suppose you jump straight up Let your velocity = (0,4,0)
Represents "jumping, going up at 4 ft/sec"
0,4,0
Example #1, cont.
Consider an elevator that goes up @ 8 ft/sec Let elevator's velocity = (0,8,0)
You ride the elevator up Your speed: (0,8,0)
1TON
Example #1, cont.
Consider: You are riding the elevator and you jump while it's going up
Final speed: Add the vectors (0,8,0) + (0,4,0) = (0,12,0) = 12 ft/sec straight up
Ans: 12 ft/sec straight up Location independent: Doesn't matter where the
elevator is
1TON
Example #1, cont.
Direction matters! Suppose elevator is going DOWN at 8 ft/sec:
(0,-8,0) You jump up: (0,4,0) Final speed: (0,-8,0) + (0,4,0) = (0,-4,0)
.
1TON
Vector Addition, Example #2
• Bird flying east at 4 mph, pushing against SW wind:
• (4,0,0) + (-0.3, -0.7, 0) = (3.7, -0.7, 0)
More on Vector Addition
• You can add more than one Vector:– Just line them up tail-to-head.– The net result goes from the first tail to the last
head.– Still commutative.
V
W
U
UWV
Point Math
Point addition = meaningless Geometrically, you can't add two points
Point + Vector = Move something in a given direction Ex: You are floating in the ocean at (100,4,22) A strong current with direction (40,0,-9) pushes
you Final location: (140,4,13): Add x,y,z components
Point Subtraction
Point – Point: Corresponds to direction to go from one point to another Ex: p = (10,5,0) q=(12,10,0) What is direction from p to q? Take: q-p ← Important! NOT p-q!!! q-p = (12,10,0) – (10,5,0) = (2,5,0) P-q = (10,5,0) – (12,10,0) = (-2,-5,0)
p
q