I am stuck on a simple yet vexing problem with basic geometry. Too bad I don;t remember my high-school co-ordinate geometry and looking for some help.
My problem is illustrated in this diagr开发者_C百科am: A rectangle rotated, scaled, and warped into a parallelogram http://img248.imageshack.us/img248/8011/transform.png
I am struggling with transforming a co-ordinate from the rectangle to a resized parallelogram. Any tips, pointers and/or code-examples would be wonderful!
Thanks, M.
There are several steps in this transformation.
- Scale about (x,y) to adjust to the final size W', H'. (Possibly unequal scaling on X and Y axes).
- Apply a shear transform to convert the rectangle to a parallelogram (keeping x,y invariant).
- Rotate about (x,y) to align to the final coordinate orientation.
- Translate to the new location.
Create the coordinate matrices for each of these and composite (multiply) them together to create the overall transform. Wikipedia could be your starting point to know about these transformation matrices.
Tip: Might be simplest to apply a translation to move (x,y) to the origin first. Then, the shear, scaling and rotation are a lot simpler to do. Then move it to the new location.
精彩评论