Message Boards Message Boards

0
|
4351 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Multiply 4-sided polygon with transformation matrix (2D)?

Posted 5 years ago

I have a transformation matrix:

p = {{-2, 0}, {1, 3}}

It is entered correctly as I get this:

MatrixForm[p]

doesn't copy and paste but is a 2x2 matrix, top row with -2 0 and bottom row has 1 3

I have a 4 sided polygon with vertices entered into a matrix, x dimension on top, y on bottom)

q = {{-2, 1, 2, -3}, {1, 3, -2, -1}}

The actual vertices are (-2,1), (1,3), (2,-2) and (-3,-1)

This gives me a 2 x 4 (r x c) matrix with top row of -2 1 2 -3 and bottom row is 1 3 -2 -1

ed at tutorials in various areas on the Wolfram site, looked through the documentation but for the

The MatrixForm function shows the proper depiction.

If I multiply the polygon by the transformation, I should end up with a 2x4 (r x c) matrix with the vertices of the polygon now being at (4,1), (-2,10), (-4,-4) and (6,-6)

I "think" this should be a simple multiply one by the other, however I get message of "incompatible shapes" or "objects of unequal length cannot be combined".

I've switched order, used both a * and . operator but all I get are the above listed error messages. I have looked at several different tutorials on the Wolfram site as well as reviewing the documentation multiple times.

I know this has to be simple but, WHAT am I doing wrong?

Tim Raeford, NC

POSTED BY: Timothy Tapio
2 Replies

Thank you! I'll have to play with this a bit, more complex than I was hoping it would be. I'd never had matrices before....so trying to learn them...and at the same time, trying to learn Mathematica. Steep learning curves for this old brain.

I appreciate your taking the time to do this....thank you again!

Tim

POSTED BY: Timothy Tapio

Your transformation matrix operates an a single vertex. You will want to transpose q so that it is a list of vertices. You will then want to use Map (/@) to map your transformation across all vertices like so

q = {{-2, 1, 2, -3}, {1, 3, -2, -1}};
p = {{-2, 0}, {1, 3}};
vertices = Transpose@{{-2, 1, 2, -3}, {1, 3, -2, -1}};
transformedvertices = p.# & /@ vertices
(* {{4,1},{-2,10},{-4,-4},{6,-6}} *)
Show[{Graphics[{FaceForm[Red], EdgeForm[Directive[Thick, Blue]], 
    Polygon[vertices]}], 
  Graphics[{FaceForm[Green], Opacity[0.1], 
    EdgeForm[Directive[Dashed, Thick, Blue]], 
    Polygon[transformedvertices]}]}]
POSTED BY: Tim Laska
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract