# Affine Transformations in Practice

## Rigid Transformations

#### Rotation

To specify a rotation you need

• an axis of rotation, a
• an angle of rotation, t
• Ra, t( P )

Three basic rotations encompass all rotations geometrical demonstration

You know the basic matrix for 2D rotation

/                \
|  cos(t)  sin(t) |
|                 |
| -sin(t)  cos(t) |
\                /

Generalize it into three dimensions

But only two are independent

• E.g., Rj,90( P ) = Ri,-90( P ) Rk,90( P ) Ri,90( P )
• Why does this work?
1. Ri,90( P ) rotates the y-axis into the z-axis
2. Rk,90( P ) rotates about the z-axis (formerly the y-axis)
3. Ri,-90( P ) rotates the z-axis (formerly the y-axis) back to the y-axis

## Non-rigid transformations

#### Scaling

Three interpretations

1. Change of units
2. Change of frame
3. Movement of point

# Clipping

What is it?

#### Representations of Lines

1. Parametric: y = mx + b, z = nx + c
2. Implicit, L(t) = P + t v = P + t ( Q - P )
• n - unit vector normal to line
• For L(t) = P + t ( Q - P )
• n . ( Q - P ) = 0
• If P is any point on the line then d( R ) = ( R - P ) . n is the signed distance to the line
• Checks (for homework)
1. If R is on the line then d( R ) = 0.
2. If R is off the line then d( R ) != 0.

#### Clip a Point against a Half-space.

Representation of a Half-space.

• Use the implicit representation of a line (P, n).
• P on the separating plane
• n perpendicular to the separating plane
• Let the direction of the normal vector point to the inside.

Calculate d = ( R - P ) \dot n

• If d > 0, inside.
• If d < 0, outside.
• If d = 0, on the line.

#### Clip a Line Segment to a Half-space.

The line segment

• L(t) = R + t ( S - R ), 0 < t < 1.
• R is at one end of the line segment
• S is at the other end

Test if each of R and S are inside. Calculate

1. d(R) = ( R - P ) \dot n
2. d(S) = ( S - P ) \dot n

There are three cases

1. Both inside: keep the segment as is.
2. Both outside: discard the segment.
3. One inside, one outside: the segment crosses the boundary of the half-space.
• Calculate the intersection
• ( L(t) - P ) \dot n = 0.
• t = { ( P - R ) \dot n } / { ( S - R ) \dot n }
• Optimize (??)
• t = { ( P - R ) \dot n } / { ( S - P ) \dot n - ( R - P )\dot. n }
• Replace one of the end points by L(t), (Which one?)

#### Clip a Line Segment to a Rectangular Parallellopiped

Straightforward, BUT what if the line segment crosses a corner?
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://www.cgl.uwaterloo.ca/wmcowan/teaching/cs488/w09/notes/l08.html", "fetch_time": 1516772836000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2018-05/segments/1516084893397.98/warc/CC-MAIN-20180124050449-20180124070449-00483.warc.gz", "warc_record_offset": 427066111, "warc_record_length": 2406, "token_count": 757, "char_count": 2442, "score": 4.59375, "int_score": 5, "crawl": "CC-MAIN-2018-05", "snapshot_type": "latest", "language": "en", "language_score": 0.7912312150001526, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00018-of-00064.parquet"}