cmsc427 geometry and vectorsreastman/slides/l03p1vectors.pdf · 2. vector math: scaling, addition,...
TRANSCRIPT
![Page 1: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/1.jpg)
CMSC427GeometryandVectors
![Page 2: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/2.jpg)
• ParametriccurvesandHw1?• Goingbeyondthecourse:generativeart• https://www.openprocessing.org• BrandonMorse,ArtDept,ART370
• Polylines,ProcessingandLab0?• QuestionsonProcessing?• https://processing.org• LearningProcessing– DanShiffman
Review: where are we?
![Page 3: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/3.jpg)
• Findalineperpendiculartoanother?
• Findsymmetricreflectingvectoronamirror?
• Findthedistancefromapointtoaline?
• Figureoutifafacetisfacingthecamera?
How can we …
![Page 4: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/4.jpg)
Polyline and points
P0
P1
P2
P3
P4
P5
• Polylineassequenceoflocations(points)
![Page 5: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/5.jpg)
Polyline and vectors
• Polylineaspointplussequenceofvectors• Assumption:displacements<<locations,fewerbits
P0
V1
V2
V3
V4
V5
![Page 6: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/6.jpg)
Polyline as vectors
• Polylineaspointplussequenceofvectors• Assumption:displacements<<locations,fewerbits
P0
V1
V2
V3
V4
V5
P1=P0+V1P2=P1+V1=P0+V1+V2
![Page 7: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/7.jpg)
Vector and vector operations
• Objects:• Points(x,y)– representposition• Vector<x,y>– representdisplacement,direction
• Operations:• Vectoraddition,subtraction,scaling• Vectormagnitude• Vectordotproduct• Vectorcrossproduct• Linear,affineandconvexcombinations
• Applications:• Representations:usingvectorsforlines,planes,others• Metrics:anglebetweenlines,distancesbetweenobjects• Tests:aretwolinesperpendicular,isafacetvisible?
![Page 8: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/8.jpg)
• Directionanddistance• Describes• Differencebetweenpoints• Speed,translation,axes
• Notation• Inbolda• Anglebracketsa =<x,y>
• Freevectors• Noanchorpoint• Displacement,notlocation
Vectors
a
a P0
P1
a =P1-P0
![Page 9: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/9.jpg)
Vector scaling
Multiplicationbyscalar sa
a 0.5a -1a = -a
![Page 10: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/10.jpg)
Vector addition and subtraction
a b
ba
c = a + b
-b
ac = a - b
![Page 11: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/11.jpg)
Vector addition and subtraction
a
b
c
Whatisc intermsofa andb?
![Page 12: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/12.jpg)
Vector addition and subtraction
a
b
c
Whatisc intermsofa andb?
a +c=b
![Page 13: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/13.jpg)
Vector addition and subtraction
a
b
c
Whatisc intermsofa andb?
a +c =b
a
b
c = b - a
![Page 14: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/14.jpg)
Coordinate vs. coordinate-free representation
Coordinate-freeequationValidfor2Dand3D
Preferwhenpossible
Coordinateequationa=<3,3>b =<4,2>
c=b- a=<4,2>- <3,3>=<1,-1>
a
b
c = b - a
![Page 15: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/15.jpg)
Parametric line in coordinate-free vector format
t = 0
t = 0.25
t = 0.75
t = 1
t = 0.5
𝑥 = 𝑡𝑑𝑥 + 𝑝𝑥𝑦 = 𝑡𝑑𝑦 + 𝑝𝑦
𝑃0
𝑃1
Set𝑽 = 𝑃1 − 𝑃0=< 𝑑𝑥, 𝑑𝑦 >
Then𝑃(𝑡) = 𝑡𝑽 + 𝑃0
Goodin2Dand3D
![Page 16: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/16.jpg)
Vector magnitude
Themagnitude(length)ofavectoris
v 4 = 𝑣64 + 𝑣74
v = 𝑣64 + 𝑣74�
Avectoroflength1.0iscalledaunitvector
Tonormalize avectoristorescaleittounitlength
n: =vv
Normalvectorsrepresentdirectionandareusedfor:lightdirection,surfacenormals,rotationaxes
![Page 17: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/17.jpg)
• Innerproductbetweentwovectors• Definedusingcoordinate-freecosinerule
Dot product
𝐚•b = a b cos(𝜃)
b
aθ
![Page 18: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/18.jpg)
• Innerproductbetweentwovectors• Definedusingcoordinate-freecosinerule
• Example:
Dot product
𝐚•b = a b cos(𝜃)
b
aθ
𝐚 =< 1,1 >𝐛 =< 1,0 >𝜃 = π/2
𝐚•b = 1.4142 ∗ 1 ∗ 0.70711 = 1b
a
θ=π/2
![Page 19: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/19.jpg)
• Given
• Then
• Inndimensions
Dot product – coordinate version
𝐚•b = 𝒂𝒙𝒃𝒙 + 𝒂𝒚𝒃𝒚
𝐚 = 𝒂𝒙, 𝒂𝒚 𝐛 = 𝒃𝒙, 𝒃𝒚
𝐚•b =O𝒂𝒊𝒃𝒊
𝒏
𝒊R𝟏
![Page 20: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/20.jpg)
• Given
• Then
• Examplerevised:
Dot product – coordinate version
𝐚•b = 𝒂𝒙𝒃𝒙 + 𝒂𝒚𝒃𝒚
𝐚 = 𝒂𝒙, 𝒂𝒚 𝐛 = 𝒃𝒙, 𝒃𝒚
𝐚 =< 1,1 >𝐛 =< 1,0 >
𝐚•b = 1 ∗ 1 + 1 ∗ 0 = 1b
a
θ=π/2
![Page 21: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/21.jpg)
• Given• Wehave
• Example
Dot product: computing angle (and cosine)
𝐚•b = a b cos(𝜃)
cos 𝜃 =𝐚•ba b
𝜃 = cosT𝟏𝐚•ba b
𝐚 =< 1,1 >, 𝐛 =< 1,0 >𝐚•b = 1 ∗ 1 + 1 ∗ 0 = 1a = 𝟏. 𝟒𝟏𝟒𝟐, b = 𝟏. 𝟎
𝐚•ba b =
𝟏𝟏. 𝟒𝟏𝟒𝟐 = 𝟎. 𝟕𝟎𝟕𝟏𝟏
cosT𝟏𝐚•ba b = 𝟎. 𝟕𝟖𝟓𝟒𝟎 =𝝅/𝟒 b
a
θ=π/4
![Page 22: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/22.jpg)
• Since
• Thenaperpendiculartobgives
• Examples
Dot product: testing perpendicularity
𝐚 ⊥ b ⇒ 𝐚 • b = 0
cos 90° = cos𝜋2 = 𝟎
𝐚 =< 1,0 >, 𝐛 =< 0,1 >𝐚•b = 1 ∗ 0 + 1 ∗ 0 = 0
𝐚 =< 1,1 >, 𝐛 =< −1,1 >𝐚•b = 1 ∗ −1 + 1 ∗ 1 = 0
![Page 23: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/23.jpg)
• Givenvector
• Theperpvectoris
• So
Perp vector and lines
=< −𝑣7, 𝑣6 >
𝐯 =< 𝑣6, 𝑣7 >
𝐯•𝐯b = 0
![Page 24: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/24.jpg)
• GivenlinesegmentP0toP1,whatlineisperpendicularthroughthemidpoint?
Midpoint bisector
P0 = (1,1)
P1= (5,3)
![Page 25: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/25.jpg)
• GivenlinesegmentP0toP1,whatlineisperpendicularthroughthemidpoint?
Midpoint bisector
v = P1-P0
P0 = (1,1)
P1= (5,3)
n = v_perp/|v_perp|
m = (P0+P1)/2
![Page 26: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/26.jpg)
• Result:bisectoris
• Withnnormalizedperpvector,mmidpoint• Appropriaterangeoft?
Midpoint bisector
v = P1-P0
P0 = (1,1)
P1= (5,3)
n = v_perp/|v_perp|
P = t n + m
m = (P0+P1)/2
𝑃 = 𝑡n +𝑚
![Page 27: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/27.jpg)
Midpoint displacement terrain (2D recursive algorithm)
• GiventwopointsP0,P1• Computemidpointm• ComputebisectorlineP=tn +m• Pickrandomt,generateP’• CallrecursivelyonsegmentsP0-P’,P’-P1
• Tuningneededonmagnitudeofdisplacement
![Page 28: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/28.jpg)
Midpoint displacement terrain (3D recursive algorithm)
• StartwithfourpointsP0,P1,P2,P3• Divide(quadsortriangles?)• Computemidpointbisector(how?)• Displace,repeat
HunterLoftis
P0 P1
P2P3
![Page 29: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/29.jpg)
• Readas“acrossb”• axbisavectorperpendiculartobothaandb,inthedirectiondefinedbytherighthandrule
Cross product
a×b
![Page 30: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/30.jpg)
• Readas“acrossb”• axbisavectorperpendiculartobothaandb,inthedirectiondefinedbytherighthandrule• Vectoraandblieintheplaneoftheprojectionscreen.• Doesaxbpointtowardsyouorawayfromyou?
Whataboutb xa?
Cross product
a×b
b
a
![Page 31: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/31.jpg)
• HowcomputenormalvectortotriangleP0,P1,P3?• Assumeupisoutofpage
Cross product: normal to plane
P0 P1
P2P3
![Page 32: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/32.jpg)
• HowcomputenormalvectortotriangleP0,P1,P3?• Assumeupisoutofpage
• Oneanswer:n=(P1-P3)x(P0-P1)
Cross product: normal to plane
P0 P1
P2P3
![Page 33: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/33.jpg)
• Parallelogramrule
• Areaofmeshtriangle?• Whenwouldcrossproductbezero?
Cross product: length of a x b
𝐚×b = a b sin(𝜃)
𝐚×b = 0
![Page 34: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/34.jpg)
• Parallelogramrule
• Areaofmeshtriangle?• Whenwouldcrossproductbezero?
• Eithera,b parallel,oreitherdegenerate
Cross product: length of a x b
𝐚×b = a b sin(𝜃)
𝐚×b = 0
![Page 35: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/35.jpg)
Cross product: computing, vector approach
𝐚×b =𝑎7𝑏h − 𝑎h𝑏7𝑎h𝑏6 − 𝑎6𝑏h𝑎6𝑏7 − 𝑎7𝑏6
![Page 36: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/36.jpg)
• Determinantof
• Computedwith3lowerminors
• with
• i,j,kareunitvectorsindirectionsofx,yandzaxes• i=<1,0,0> j=<0,1,0> k=<0,0,1>
Cross product: computing, matrix approach
𝐚×b =𝑖 𝑗 𝑘𝑎6 𝑎7 𝑎h𝑏6 𝑏7 𝑏h
𝐚×b = 𝑖𝑎7 𝑎h𝑏7 𝑏h − 𝑗
𝑎6 𝑎h𝑏6 𝑏h + 𝑘
𝑎6 𝑎7𝑏6 𝑏7
𝑎 𝑏𝑐 𝑑 = 𝑎𝑑 − 𝑐𝑏
![Page 37: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/37.jpg)
Midpoint of triangle?
P0
P1
P2?
![Page 38: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/38.jpg)
Midpoint of triangle?
P0
P1
P2?
Answer1:
𝑚 =𝑃0 + 𝑃1 + 𝑃2
3
![Page 39: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/39.jpg)
Midpoint of triangle?
Answer2:Doubleinterpolation(blending)
Firstinterpolation:vectorlineP0toP1
Midpointatt=0.5
𝑃 = 𝑡𝑉 + 𝑃0
P0
P1
P2
m0= 𝑡(𝑃1 − 𝑃0) + 𝑃0= 𝑡𝑃1 + (1 − 𝑡)𝑃0
𝑚0 = 0.5𝑃1 + (1 − 0.5)𝑃0= 0.5𝑃1 + 0.5𝑃0
=𝑃1 + 𝑃0
2
![Page 40: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/40.jpg)
P0
P1
P2
m0
m
Midpoint of triangle?
Answer2:Doubleinterpolation
Secondinterpolation:vectorlinem0toP2
Midpointats=1/3
𝑃 = 𝑠𝑉′ + 𝑚0= 𝑠(𝑃2 −𝑚0) +𝑚0= 𝑠𝑃2 + 1 − 𝑠 𝑚0
𝑚0 =13𝑃2 + 1 −
13 𝑚0
=13𝑃2 +
23𝑚0 =
𝑃2 + 𝑃1 + 𝑃03
=13𝑃2 +
23 (0.5𝑃1 + 0.5𝑃0)
![Page 41: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/41.jpg)
Generalizing: convex combinations of points
AconvexcombinationofasetofpointsSisalinearcombinationsuchthatthenon-negativecoefficientssumto1
withand𝐶 = O 𝛼t𝑃t
�
utvw
O𝛼t = 1�
0 ≤ 𝛼t ≤ 1
![Page 42: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/42.jpg)
Generalizing: convex combinations of points
AconvexcombinationofasetofpointsSisalinearcombinationsuchthatthenon-negativecoefficientssumto1
withand
Isthisequationforalinesegment aconvexcombination?
𝐶 = O 𝛼t𝑃t
�
utvw
𝑃 = 𝑡𝑃1 + (1 − 𝑡)𝑃0
O𝛼t = 1�
0 ≤ 𝛼t ≤ 1
![Page 43: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/43.jpg)
Generalizing: convex combinations of points
AconvexcombinationofasetofpointsSisalinearcombinationsuchthatthenon-negativecoefficientssumto1
withand
Isthisequationforalinesegment aconvexcombination?
Yes.Withtin[0,1],tand(1-t)>=0,andt+(1-t)=1
𝐶 = O 𝛼t𝑃t
�
utvw
𝑃 = 𝑡𝑃1 + (1 − 𝑡)𝑃0
O𝛼t = 1�
0 ≤ 𝛼t ≤ 1
![Page 44: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/44.jpg)
Generalizing: convex combinations of points
AconvexcombinationofasetofpointsSisalinearcombinationsuchthatthenon-negativecoefficientssumto1
withand
Isthisequationforatriangleaconvexcombination,assumingsandtarein[0,1]?
𝐶 = O 𝛼t𝑃t
�
utvw
𝑃 = 𝑠𝑃2 + (1 − 𝑠)(𝑡𝑃1 + 1 − 𝑡 𝑃0)
O𝛼t = 1�
= 𝑠𝑃2 + (1 − 𝑠)(𝑡𝑃1) + (1 − 𝑠) 1 − 𝑡 𝑃0)= 𝑠𝑃2 + (𝑡 − 𝑠𝑡)𝑃1 + (1 − 𝑠 − 𝑡 + 𝑠𝑡)𝑃0
0 ≤ 𝛼t ≤ 1
![Page 45: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/45.jpg)
Generalizing: convex combinations of points
AconvexcombinationofasetofpointsSisalinearcombinationsuchthatthenon-negativecoefficientssumto1
withand
Forgeneralpolygon,allconvexcombinationsofverticesyieldsconvexhull
𝐶 = O 𝛼t𝑃t
�
utvw
O𝛼t = 1�
0 ≤ 𝛼t ≤ 1
![Page 46: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/46.jpg)
Linear, affine and convex combinations
Linear: Noconstraintsoncoefficients
Affine: Coefficientssumto1
with
Convex: Coefficientssumto1,eachin[0,1]
withand
𝐶 = O 𝛼t𝑃t
�
utvw
O𝛼t = 1�
0 ≤ 𝛼t ≤ 1
𝐶 = O 𝛼t𝑃t
�
utvw
𝐶 = O 𝛼t𝑃t
�
utvw
O𝛼t = 1�
![Page 47: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/47.jpg)
Linear combinations of points vs. vectors
Point– pointyieldsa….
Vector– vectoryieldsa…
Point+vectoryieldsa…
Point+pointyieldsa…
![Page 48: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/48.jpg)
Linear combinations of points vs. vectors
Point– pointyieldsa….vector
Vector– vectoryieldsa… vector
Point+vectoryieldsa… point
Point+pointyieldsa… ????Notdefined
VectorsareclosedunderadditionandsubtractionAnylinearcombinationvalid
PointsarenotAffinecombinationthatsumsto0yieldsvectorAffinecombinationthatsumsto1yieldspointConvexcombinationyieldspointinconvexhull
Moral:Whenprogrammingw/pts&vtrs,knowtheoutputtype
![Page 49: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/49.jpg)
Applying vectors operations to polygons
Isapolygonwindingclockwise?
Isapolygonconvex?
Isapolygonsimple?
Lab1:addthesemethodstoPolylineclass
![Page 50: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/50.jpg)
1. Normalformofline2. Normalformofplane3. Programmingwithpointsandvectors4. Signofdotproduct5. Tweening6. Distancefrompointtoline
If time allows …
![Page 51: CMSC427 Geometry and Vectorsreastman/slides/L03P1Vectors.pdf · 2. Vector math: scaling, addition, subtraction 3. Coordinate and coordinate-free formulas 4. Vector magnitude and normalization](https://reader035.vdocuments.net/reader035/viewer/2022071000/5fbcebfffc33ea4c3c5c4b38/html5/thumbnails/51.jpg)
1. Notationforvectors<x,y>andpts(x,y)2. Vectormath:scaling,addition,subtraction3. Coordinateandcoordinate-freeformulas4. Vectormagnitudeandnormalization5. Dotproductsandcosinerule6. UsingOctaveOnlineasvectorcalculator7. Dotproduct,perpendicularityandperpvector8. Midpointbisector9. Midpointdisplacementalgorithm10. Crossproduct,righthandruleandsinerule11. Computingcrossproductwithdeterminant12. Linear,affineandconvexcombinations13. Trianglemidpoint
What you should know after today