# Affine transformations & Affine spaces

Can Sage do affine transformation in affine spaces - adding a vector to a point?

Affine transformations & Affine spaces

Can Sage do affine transformation in affine spaces - adding a vector to a point?

add a comment

0

Yes, just represent your points with position vectors. Sage can add vectors to vectors and apply linear transformations to vectors.

For example:

```
sage: v = vector([1,2,3])
sage: M = matrix([[1,0,0],[0,2,0],[0,1,1]])
sage: M
[1 0 0]
[0 2 0]
[0 1 1]
sage: pt = vector([0,1,0])
sage: v + M*pt # apply affine linear transformation to point `pt`
(1, 4, 4)
```

0

Thanks Benjamin:

I am aware how it could be used in vector algebra. The source I use is Geometric Tools for Computer Graphics by Schneider & Eberly 2003.

There is a distinction unlike vector algebra between a vector and a point. *Add two vectors to get a third. *Multiply a vector by a scalar to get a vector. *Add a vector to a point to get another point. *Subtract two points to get vector. (edited) *etc.

In affine algebra, a point can be translated in a matrix multiplication where in vector algebra it cannot. I have to admit that vector algebra is used quite a lot in CG, for example, the affine matrix has a vector matrix embedded.

The elements of a point in affine space for example is [0, 1, 0, 1] for the vector [0, 1, 0] in vector space. The elements for a vector in affine space is [0, 1, 0, 0] for the vector [0, 1, 0] in vector space.

Please don't ask me to prove this. I do believe that sage developers can implement this as a subset to the module linear algebra. CG is a large and fast growing business.

I suppose the answer from Benjamin is NO. There is no affine algebra unless we define the vectors as points and the matrices as affine matrices....

Many Thanks

It sounds to me like you are talking about realizing affine linear transformations of 3-dimensional space as linear transformations of 4 dimensional space followed by a projection. If you can describe the projection in terms of linear algebra, then you could easily implement affine linear transformations your sense extending the basic linear algebra framework in Sage.

@benjaminfjones: This is in a lot of elementary Lie group or algebra books nowadays, and is sort of what you are saying. See http://en.wikipedia.org/wiki/Affine_transformation, for instance. It's actually a neat exercise to prove similar properties for these sets of matrices as for GL or SL or whatever. Anyway, I don't see why this couldn't be implemented pretty easily. I think we also have quaternions in Sage which also are used in a similar fashion for CG.

Asked: **
2011-10-29 07:26:46 -0500
**

Seen: **318 times**

Last updated: **Oct 29 '11**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.