Ask Your Question

Affine transformations & Affine spaces

asked 2011-10-29 07:26:46 -0500

MageSean gravatar image

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

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2011-10-29 08:22:55 -0500

benjaminfjones gravatar image

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)
edit flag offensive delete link more

answered 2011-10-29 09:06:15 -0500

MageSean gravatar image

updated 2011-10-29 09:17:57 -0500

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

edit flag offensive delete link more


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 gravatar imagebenjaminfjones ( 2011-10-29 11:02:24 -0500 )edit

@benjaminfjones: This is in a lot of elementary Lie group or algebra books nowadays, and is sort of what you are saying. See, 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.

kcrisman gravatar imagekcrisman ( 2011-10-29 14:16:15 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


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

Seen: 278 times

Last updated: Oct 29 '11