|
| 1 | +# Affine Operations Pipeline |
| 2 | + |
| 3 | +The `affine-ops` pipeline applies a sequence of operations to an affine transform. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +```bash |
| 8 | +affine-ops input-transform output-transform operations |
| 9 | +``` |
| 10 | + |
| 11 | +Where: |
| 12 | +- `input-transform`: An input affine transform file |
| 13 | +- `output-transform`: The output transform file after applying operations |
| 14 | +- `operations`: A JSON array of operations to apply sequentially |
| 15 | + |
| 16 | +## Operations Format |
| 17 | + |
| 18 | +The operations parameter should be a JSON array where each element describes an operation to apply to the affine transform. Each operation object must have a `method` field specifying the operation type. |
| 19 | + |
| 20 | +### Supported Operations |
| 21 | + |
| 22 | +#### SetIdentity |
| 23 | +Resets the transform to identity. |
| 24 | +```json |
| 25 | +{"method": "SetIdentity"} |
| 26 | +``` |
| 27 | + |
| 28 | +#### Translate |
| 29 | +Translates the transform by a vector. |
| 30 | +```json |
| 31 | +{ |
| 32 | + "method": "Translate", |
| 33 | + "translation": [x, y, z], |
| 34 | + "pre": false |
| 35 | +} |
| 36 | +``` |
| 37 | +- `translation`: Vector of translation values (length must match transform dimension) |
| 38 | +- `pre`: Optional boolean, if true applies pre-composition (default: false) |
| 39 | + |
| 40 | +#### Scale |
| 41 | +Scales the transform by a factor or vector of factors. |
| 42 | +```json |
| 43 | +{ |
| 44 | + "method": "Scale", |
| 45 | + "factor": 2.0, |
| 46 | + "pre": false |
| 47 | +} |
| 48 | +``` |
| 49 | +or |
| 50 | +```json |
| 51 | +{ |
| 52 | + "method": "Scale", |
| 53 | + "factor": [2.0, 1.5, 0.8], |
| 54 | + "pre": false |
| 55 | +} |
| 56 | +``` |
| 57 | +- `factor`: Scalar value or vector of scale factors |
| 58 | +- `pre`: Optional boolean, if true applies pre-composition (default: false) |
| 59 | + |
| 60 | +#### Rotate |
| 61 | +Rotates around two axes by an angle. |
| 62 | +```json |
| 63 | +{ |
| 64 | + "method": "Rotate", |
| 65 | + "axis1": 0, |
| 66 | + "axis2": 1, |
| 67 | + "angle": 1.57, |
| 68 | + "pre": false |
| 69 | +} |
| 70 | +``` |
| 71 | +- `axis1`, `axis2`: Axis indices for rotation plane |
| 72 | +- `angle`: Rotation angle in radians |
| 73 | +- `pre`: Optional boolean, if true applies pre-composition (default: false) |
| 74 | + |
| 75 | +#### Rotate2D (2D transforms only) |
| 76 | +Rotates in 2D by an angle. |
| 77 | +```json |
| 78 | +{ |
| 79 | + "method": "Rotate2D", |
| 80 | + "angle": 1.57, |
| 81 | + "pre": false |
| 82 | +} |
| 83 | +``` |
| 84 | +- `angle`: Rotation angle in radians |
| 85 | +- `pre`: Optional boolean, if true applies pre-composition (default: false) |
| 86 | + |
| 87 | +#### Rotate3D (3D transforms only) |
| 88 | +Rotates around a specified axis. |
| 89 | +```json |
| 90 | +{ |
| 91 | + "method": "Rotate3D", |
| 92 | + "axis": [0, 0, 1], |
| 93 | + "angle": 1.57, |
| 94 | + "pre": false |
| 95 | +} |
| 96 | +``` |
| 97 | +- `axis`: 3D vector specifying rotation axis |
| 98 | +- `angle`: Rotation angle in radians |
| 99 | +- `pre`: Optional boolean, if true applies pre-composition (default: false) |
| 100 | + |
| 101 | +#### Shear |
| 102 | +Applies a shear transformation. |
| 103 | +```json |
| 104 | +{ |
| 105 | + "method": "Shear", |
| 106 | + "axis1": 0, |
| 107 | + "axis2": 1, |
| 108 | + "coef": 0.5, |
| 109 | + "pre": false |
| 110 | +} |
| 111 | +``` |
| 112 | +- `axis1`, `axis2`: Axis indices for shear |
| 113 | +- `coef`: Shear coefficient |
| 114 | +- `pre`: Optional boolean, if true applies pre-composition (default: false) |
| 115 | + |
| 116 | +## Example |
| 117 | + |
| 118 | +```bash |
| 119 | +# Create an affine transform |
| 120 | +create-affine-transform identity.iwt |
| 121 | + |
| 122 | +# Apply operations: reset to identity, translate, then scale |
| 123 | +affine-ops identity.iwt result.iwt \ |
| 124 | + '[ |
| 125 | + {"method": "SetIdentity"}, |
| 126 | + {"method": "Translate", "translation": [1.0, 2.0, 3.0]}, |
| 127 | + {"method": "Scale", "factor": 2.0} |
| 128 | + ]' |
| 129 | +``` |
| 130 | + |
| 131 | +This will create a transform that first translates by (1,2,3) and then scales by a factor of 2. |
0 commit comments