# Matrix help: Need to move, rotate, scale and taper

**URL:** <https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503>\
**Category:** Rhino Developer\
**Tags:** windows\
**Created:** [January 18, 2023, 3:28pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503 "2023-01-18T15:28:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [January 18, 2023, 3:28pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/1 "2023-01-18T15:28:51Z")

</div>

Hi guys,  
I am working on a tool to transform data from one map projection to another and I need to figure out how to make a transformation matrix, but this stuff is hard to understand.

Is there a tool where we can define the eight corners of a “cube” in two spaces and have a matrix generated from that?

Basically I need to figure out how to make a matrix for a situation like this where I know the corresponding corners:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/9/b/99b420f223e789d44c2afd12d3216d07e1b27cf3.png)

( I presume flow along surface uses a complex version of this, thus the question)

---

<div class="post-metadata">

**Author:** ![jeremy5](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jeremy5/32/493741_2.png) [@jeremy5](https://discourse.mcneel.com/u/jeremy5)\
**Post date:** [January 18, 2023, 3:45pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/2 "2023-01-18T15:45:19Z")

</div>

Hi Holo,

Just to be 100% clear about your drawing, you are illustratinging a 3D rotation and not a taper? You only need to cater for the specific transforms in the title: move rotate and scale?

Regards  
Jeremy

---

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [January 18, 2023, 4:12pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/3 "2023-01-18T16:12:57Z")

</div>

No, it’s a taper.  
Backstory:  
I use pyproj to project the center of the bounding box + an offset of that center point.  
Then I move the objects and rotates by evaluating the offsetpoints angle.

This works fine and fast, but I see I get a different result if I translate with pyproj every single point of the polylines, as there is a small taper involved. Thus the request to use a transformation matrix instead of move+rotate.

But I compared two maps that were “correctly” positioned and aligned from another software, and there they had only moved and rotated. No taper involved, and I think that might be a better solution so I don’t mess with too much data.

Baseline: **I think I am good as it is** , no need to over-perform. But it would be cool to know anyway though.

---

<div class="post-metadata">

**Author:** ![Mahdiyar](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/mahdiyar/32/472862_2.png) [@Mahdiyar](https://discourse.mcneel.com/u/Mahdiyar)\
**Post date:** [January 18, 2023, 4:18pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/4 "2023-01-18T16:18:02Z")

</div>

There’s a Transform output on every transformation component in grasshopper. You can use that to find the matrix.  
 ![Matrix](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/5/8/0/5807c0456a467bbf1d14e108a672bfb717cb691e.gif)  
As Jeremy mentioned, matrices can only be used for Affine and Perspective transformations. Transformation matrices can’t do the following operations:

- BendSpaceMorph
- FlowSpaceMorph
- MaelstromSpaceMorph
- SplopSpaceMorph
- SporphSpaceMorph
- StretchSpaceMorph
- TaperSpaceMorph
- TwistSpaceMorph

You can also add two or more transformation matrices using the [Compound](https://grasshopperdocs.com/components/grasshoppertransform/compound.html) component.

---

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [January 18, 2023, 4:19pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/5 "2023-01-18T16:19:45Z")

</div>

Thanks, that explains a lot, also why shear was explained in the tutorial and not taper 🙂

> **[2 Matrices and Transformations](https://developer.rhino3d.com/guides/general/essential-mathematics/matrices-transformations/)**
>
> This guide reviews matrix operations and transformations.

---

<div class="post-metadata">

**Author:** ![jeremy5](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jeremy5/32/493741_2.png) [@jeremy5](https://discourse.mcneel.com/u/jeremy5)\
**Post date:** [January 18, 2023, 4:42pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/6 "2023-01-18T16:42:43Z")

</div>

> [@Mahdiyar](#):
>
> matrices can only be used for Affine and Perspective transformations

I believe that, technically, higher order transformations like taper can be applied via matrices if you are permitted to place formulae in the cells rather than constants. Whether Rhino can accommodate formulae I have no idea (I’m already well into territory where the mathematical part of my brain is hurting). Maybe @rajaa could answer that.

---

<div class="post-metadata">

**Author:** ![Holo](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/holo/32/496872_2.png) [@Holo](https://discourse.mcneel.com/u/Holo)\
**Post date:** [January 18, 2023, 5:29pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/7 "2023-01-18T17:29:41Z")

</div>

> [@jeremy5](#):
>
> (I’m already well into territory where the mathematical part of my brain is hurting)

Well, then that’s obviously above mine too! So I’ll happily stick with move and rotate 😉 Thanks for taking the time though.

But if you find a way to make it easy to kind of transform stuff from one box to another then that could be a smooth tool for a select few in the future.

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [January 24, 2023, 6:19pm UTC](https://discourse.mcneel.com/t/matrix-help-need-to-move-rotate-scale-and-taper/153503/8 "2023-01-24T18:19:34Z")

</div>

> [@Holo](#):
>
> to kind of transform stuff from one box to another

Maybe this?

[SampleCsBoxMorph.cs](https://github.com/mcneel/rhino-developer-samples/blob/7/rhinocommon/cs/SampleCsCommands/SampleCsBoxMorph.cs)

Easily ported to Python…

– Dale
