Loading [MathJax]/jax/output/CommonHTML/jax.js

학교수업/수치해석

[Numerical Analysis] 3. Transformation

hwijin97 2022. 5. 19. 18:51

Transformantion

To Change geometric structure such as translations, scaling, rotations, and combinations of them

 

Translation

- position : changed

- size, angle, ... : unchanged

 

Scaling

size: changed:

- position, angle, ... : unchanged

 

Rotation

angle: changed:

- size, position, ... : unchanged

 

Unchanged properties : Invariant

 

 

 

Geometric Properties

- Position : Distance from the origin

- Distance : Relative distance ( size )

- Angle : Relative angle

- Orientation : Absolute angle

- Collineation : Preseves lines ( points on a line also form a line afeter the transformation ) L' = T(L), P' = T(P) -> Line

- Distance-preseving : Distance between any two points is preserved after the transformation, Preseve angles, area, and volume

- Conformal : Preserve angles

 

 

Geometries

- Congruent geometry : Sizes and shapes anre identical

- Conformal geometry : corresponding angles are equal

- Affine geometry : Parallel lines remain parallel and ratios are preservved

- Projective geometry : Straight lines remain straight

 

 

Isometries

- Also called as rigid-body transformation

- distance-preserving map

- rigid-body motion

- include translations, rotations, reflections

- Equations describing general 2D isometries : x=ax+by+tx,y=cx+dy+ty[abcd]T=[abcd]1,|abcd|=±1

- x,y : original coordinates, x,y : transformed, tx,ty : translation

 

Similarities

- Preseve shapes - isometry + scaling (uniform)

- Also called as conformal transformation

 

Shear

- Slanting an axis

- Translate along an axis and the amount of translation is proportional to its coordinates

- x=ax+by,y=cx+dy -> x direction : a = d = 1, b = k, c = 0 || y direction : a = d = 1, b = 0, c = k

 

Affines

- Collinearity ( Points on AB are transformed to points on A'B')

- Preseve parallelism : AB parallel to CD -> A'B' parallel to C'D'

- Preserve ratios : EA : EB = E'A' : E'B'

 

Linear Transformations

- Homogeneous linear system X=MX

- Linaer Transformation + Translation = Affine Transformation X=MX+T

 

 

Scaling

- Uniform scaling ( Isotropic ) : same scales for all axes

- Non-uniform scaling : Different scale for each axis

 

Translation

- X=X+T, T : vector

 

Rotations

- x=|P|cos(θ+ω),y=|P|sin(θ+ω)

- |P|=|P| : length invarient

- x=xcosθysinθ,y=xsinθ+ycosθ ( 2D )

- X=RX, |R|=1

- R1=RT -> orthogonal matrix

 

Rotation around a point P

1. Translate P to the origin ( X=XP )

2. Rotate around the origin ( X=RX )

3. Translate the origin to P ( X=X+P )

=> X=R(XP)+P

 

Homogeneous Coordinates

- Except translations, all transformations can be represented as homogeneous systems, and corresponding matrix multiplications , X=M3M2M1X,X=(M3M2M1)1X

- Including translations, they can be represented as matrix products and vector additions ( X=MX+T )

 

-> Points on the x-y plane in 3D are equivalent to the point in 2D 

-> 2D point represent to 3D point X=(hx,hy,h)ifh=1,X=(x,y,1)

 

- Shear transformation in xy direction

X=SX=[10a01b001][hxhyh]=[hx+hahy+hbh]

X=(h(x+a),h(y+b),h)X=(x+a,y+b) in 2D

- 3D points can be also represented in 4D

- Express translations with matrix products ( n-dim translations -> n+1-dim shear transformation )

M=[M001],T=[IT01]

- For computational efficiency, use h = 1

 

 

Orthogonal Matrix

- Definition : if AAT=I, then A is an orthogonal matrix

- By definition of inverse matrix : A1=AT

- Orthonormal : Two vectors are orthonormal if they are orthogonal and both of unit length

- Theorem : if vectors V1,,Vn form an orthonormal set, then n x n matrix constructed by setting the i-th column equal to Vi is orthogonal

    - Proof : if vectors V1,Vn are orthonormal ViVj=δij. Since i-th row of AT is Vi, (i,j) element of ATA is ViVj=δij, therefore AT=A1

- Theeorem : if the n x n matrix M is orthogonal, then M preserves lengths and angles

    - Proof : 1. Length : MXMX=(MX)T(MX)=XTMTMX=XTX=XX

    - Angle: XY=|X||Y|cosθ,θ=cos1(XY|X||Y|)=cos1(MXMX|MX||MY|), therefore, if MXMY=XY, angle is preserved. MXMY=(MX)TMY=XTMTMY=XTY=XY

 

- Rotation Matrix is orthogonal matrix

    - 3D : (RxRyRz)1=R1zR1yR1x=RTzRTyRTx=(RxRyRz)T

 

Transforming Normal Vectors

- is the transformed normal vector still the normal vector? (perpendicular to the surface?)

    - Tangent vector : direction of the surface at a point

    - Let G be the transformation with which GN become the normal vector of the transformed surface (GN)(MT)=(GN)T(MT)=NTGTMT=0, Since NTT=0,G=M if M is orthogonal

 

 

Translation of Coordinate System

- Translating coordinate system is equivalent to oppositely translating points ( X=T1X )

( T 만큼 translation 한다는것은, Coordinate system을 T 만큼 translation 한것과 동일하다는 뜻 )

 

Rotation of Coordinate System

- Rotating coordinate system is equivalent to oppositely rotating points ( X=R1X )

 

Transformation of Coordinate System

- Rotation + Translation ( X=(TR)1X=R1T1X )

- New coordinate system is specified by

    - Origin : X0

    - Coordinate axes : U,V,N ( in 3D )

    - N can be derived from U and V N=U×V|U×V|

 

 


Reflection and Inversion

 

- Reflection across a line m

    - Reflectioin about a line m passing through the origin : R=[cosθsinθsinθcosθ], X=R[1001]R1X

    - Reflection about a line m passing through a point P(a,b) : T=[10a01b001], X=TR[100010001]R1T1X

 

- Inversion in a point P

    - inversion in a point P(a,b) : X=T[100010001]T1X,T=[10a01b001]

 

- 3D Reflection

    - xy : x=x,y=y,z=1 : [100010001]$ ...

- Reflection about a plane passing through a poiint P(a,b,c) and habing a normal vector N

    - T=[abc]T

    - R : Rotation to move N to z - axis ( 다른방법으로 xyz -> N UZ 으로 rotation 하는 R 을 이용해도됨 )

    - X=TR1FxyRT1X

 

3D Rotation

- Counter-clockwise rotation around axis (axis coordinate is same, other axis coordinate is roated by θ )

- Right-handed coordinate system

 

Rotation

- Rotation by θ around an arbitrary axis A

    1. Rotate around z axis by α so that A lies on the x-z plane. Let Axy be projection of A onto x-y plane, then α = angle between Axy and x axis X=RαX Rα : clock wise rotation with z axis

    2. Rotate around y axis by β which is the angle between RαA and x axis ( X=RβRαX )

    3. Rotate around x axis by θ ( X=RθRβRαX )

    4. Rotate around y axis by β ( X=R1βRθRβRαX )

    5. Rotate around z axis by α ( X=R1αR1βRθRβRαX )

 

- Rotate P by θ around an arbitrary axis A

    - Decompose P into projAP and perpAP

        - projAP : parallel to A : Not changed after rotation

        - perpAP : perpendicular to A

        - |A|=1

    - projAP=projAP

    - P=projAP+perpAP

    - projAP=(AP)A,perpAP=P(AP)A

    - perpAP=(A×P)sinθ+(perpAP)cosθ

    - P=projAP+perpAP=Pcosθ+(A×P)sinθ+A(AP)(1cosθ) 

 

- Arbitrary rotations in 3D

    - Represent the rotation as a product of successive rotations arounde ach axes

    - Different orders produce different results

 

Rotations - Euler Angles

- Arbitrary rotations in 3D ( Pitch (x), Roll (y), Yaw (z) )

    - can be achieved by a product of three elemental rotations ( rotations around a axis)

    - Various combinations are possible 

- Gimbal Lock

    - A rotation in one axis could override a rotation in another => loss of a degree of freedom

    - ex) Y axis rotated 90 degrees in X-Y-Z rotation => Z axis aligned to X axis

- Interpolation problems

    - Interpolate between two rotations

    - Calculated interpolations may not be smooth

 

Quaternions

 

- An alternative to Euler angles for representing rotation

- Somewhat less intuitive

- More predictable behavior and smooth interpolations

 

- Invented by William Hamilton as a non-commutative generalization to complex numbers

- 4-tuple : w+xi+yj+zk, where i,j,k are special imaginaries (just like i in complex number)

    - i2=j2=k2=1 , ij=ji=k, jk=kj=i, ki=ik=j

 

Quaternions and Rotation

- Any rotation in 3-space can be encoded as a quaternion : (w,x,y,z)

- Quaternions for simple rotation around each axis

    - qx=(cosα2,sinα2,0,0)

    - qy=(cosβ2,0,sinβ2,0)

    - qz=(cosγ2,0,0,sinγ2)

- Euler angles : multiply simple rotations : q=qxqyqz(X=RxRyRzX)

- Quaternion (w,x,y,z) to matrix

Rq=[12y22z22xy2wz2xz+2wy2xy+2wz12x22z22yz2wx2xz2wy2yz+2wx12x22y2]

- Interpolation : Interpolating points on a 4D unit sphere, Unique path between two rotations, More predictable and statble

 

Projection

 

Projection : World (3D) -> Screen (2D)

- Parallel (or orthogonal) projection

- Perspective projection

 

Parallel Projection

- Lengths may be scaled

- Angles may not be preserved

- Preserves parallelism of lines

 

Perspective Projection

- Lengths may be scaled

- Angles may not be preserved

- Parallelism of lines may not be preserved

- Perspective foreshortening

    - Near objects appear larger

 

Parallel Projection

Projection on the plane, z=d -> x,y is same, z=d

 

Perspective Projection

Plane z=d->

xd=xz => x=xzd

yd=yz => y=yzd

z=d=zzd

M=[100001000010001d0]

 

 

Lines in 3D Space

- A line passing through a point S and having a direction V -> P=S+tV

- Distance between a point Q and a line

d2=|QS|2|projV(QS)2|=|QS|2|(QS)V|V|2V|2

- Distance between two lines : P1,P2, P1=S1+t1V1,P2=S2+t2V2

    - minimun of |P1(t1)P2(t2)|

    - |P1(t1)P2(t2)|2=P1P1+P2P22P1P2=At21+Bt22+Ct1+Dt2+Et1t2+F

    - ft1=0,ft2=0

    - (V1V2)2V21V22=0 => Two lines are parallel, Distance between the line and any point on the line

 

Planes in 3D Space

plane : ax+by+cz+d=0, N(XP)=0, L=<N,NP>=<N,D>, (|N|=1)

- Distance between a point Q and a plane

    - d=NQNP=LQ

    - 1. d = 0, Q is on the plane

    - 2. d > 0, Q is in the positive side (normal vector direction)

    - 3. d < 0, Q is in the negative side (opposite direction of normal vector)

- Intersection between three planes

    - N1QN1P1=0

    - N2QN2P2=0

    - N3QN3P3=0

    - Q=M1[N1P1N2P2N3P3]

- Intersection between two planes : line

    - N1QN1P1=0

    - N2QN2P2=0

    - Q=[N1N2N1×N2]1[N1P1N2P20]

    - P=Q+t(N1×N2)

 

- Distance between a point Q and a plane

    - N(QP)=0,Q=QdN

    - N(QdNP)=0

    - d=N(QP)=LQ

 

Transforming Planes

- Plane : L=<N,D>=<N,NP> ( D=NP )

- Transformation F=TM=[MT01], (M : Linear Transformation, T : Translation )

    - LL=<N,D>

    - N' = (M^{-1}^TN, P=FP

    - D=NP=N(FP)=((M1)TN)(MP+T)=((M1)TN)T(MP+T)=NTM1MPNTM1T=DNM1T

    - L=(F1)TL

 

 

'학교수업 > 수치해석' 카테고리의 다른 글

[Numerical Analysis] 6. Rendering  (0) 2022.05.20
[Numerical Analysis] 5. Surface  (0) 2022.05.20
[Numerical Analysis] 4. Curve  (0) 2022.05.20
[Numerical Analysis] 2. Matrix  (0) 2022.05.19
[Numerical Analysis] 1. Vector, Line, Plane  (0) 2022.05.19