Notes on linear transformations

栏目: IT技术 · 发布时间: 6年前

内容简介:To place an object on a screen, you typically need to:This post explores well-known methods to,orobjects, and tomultiple transformations at once.If you think of an object as a set of points in a coordinate system, you can describe characteristics of the ob

To place an object on a screen, you typically need to:

  1. Move the object to the desired location.
  2. Scale the object to fit well with other objects.
  3. Rotate the object to the desired orientation.

This post explores well-known methods to,orobjects, and tomultiple transformations at once.

Describing the position of objects

If you think of an object as a set of points in a coordinate system, you can describe characteristics of the object such as its position and shape with the position of each point.

The canonical example of a point set is a rectangle:

Notes on linear transformations
Note how the points change during this scale transformation.

You can think of these points as offset vectors from the origin or n by 1 matrices. By modifying these matrices with mathematical operations, you can effectively change attributes from the object.

More specifically, you can do a linear transformation using a matrix to transform this vector. For example, for n = 2 :

a b
c d
x
y
=
x’
y’

There are certain matrix configurations that produce known results, by modifying values on this known matrices, you can,oran object.

You can alsocombine multiple transformationsinto a single matrix that performs all the transformations at once.

This post focuses on two-dimensional transformations because they are easier to understand, but the concepts work in any space.

Scaling is used to make an object bigger or smaller, mathematically this means multiplying each coordinate by a constant.

You scale an object uniformly with a matrix that has the following shape:

scale(sx, sy) =
s x 0
0 s y
x
y
=
s x x
s y y

Below is a live example you can play with, move the slider to see how different values change the box:

You scale uniformly across different axis by giving different values to sx and sy or scale only in one axis by keeping the other constant. Here is an example of scaling only affecting the y axis:

Reflection

You can reflect a vector across either of the axes by using a negative scale factor. In the example below, the rectangle is reflected horizontally by using a scaling factor of -1 in the x axis.

To rotate each point about the origin with the same angle use rotation transforms.

To rotate an object by an angle ϕ , you need to:

rotate(ϕ) =
cos(ϕ) -sin(ϕ)
sin(ϕ) cos(ϕ)
x
y

In the example below, you can see a rotation matrix in action ( ϕ defined in radians.) You can move the slider to see the values update.

Shear transforms pushes or “tilts” objects vertically or horizontally.

To shear an object vertically, you can use the following matrix:

shear-y(s) =
1 0
s 1
x
y

And to shear an object vertically you can use:

shear-x(s) =
1 s
0 1
x
y

Combining transformations

You can subsequently apply multiple transformations one after the other to the same object to get a more complex transformation, for example, given this box:

If you apply a scale(1.3) transformation, you get:

If you subsequently apply a shear-x(-0.3) transform, you get the final result of:

You can express the following example as a composition: shear-x(scale(X)) , and apply multiple transforms to end up with a desired object:

1.3 0
0 1.3
1 0
-0.3 1
x
y
=
1.3 0
-0.30 1.3
x
y

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

MATLAB在数学建模中的应用

MATLAB在数学建模中的应用

卓金武 编 / 北京航空航天大学 / 2011-4 / 34.80元

《MATLAB在数学建模中的应用》从数学建模的角度介绍了MATLAB的应用。《MATLAB在数学建模中的应用》的4位作者均具有实际的数学建模参赛经历和竞赛指导经验。书中内容完全是根据数学建模竞赛的需要而编排的,涵盖了绝大部分数学建模问题的MATLAB求解方法。 《MATLAB在数学建模中的应用》内容分上下两篇。上篇介绍数学建模中常规方法MATLAB的实现,包括MATLAB交互、数据建模、程序......一起来看看 《MATLAB在数学建模中的应用》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具