Rotate Scale Shear a grid
configuration-examples Rotate Scale Shear a grid
The script presents an example how you can rotate, stretch and shear a raster domain.
example
container Geography { unit<fpoint> rdc_meter: range = "[{300000, 0}, {625000, 280000})"; } container parameters { unit<float32> meter := BaseUnit('meter', float32); parameter<meter> gridsize := 1000[meter]; parameter<meter> NL_grid_X_min := 270000[meter]; parameter<meter> NL_grid_Y_min := 325000[meter]; parameter<meter> X_org := ( 0f + (NL_grid_Y_min / 2f))[meter]; parameter<meter> Y_org := (375000f - (NL_grid_X_min / 2f))[meter]; parameter<uint32> aantalkolommen := uint32(((NL_grid_Y_min + NL_grid_X_min)*(sqrt(2f) / 2f)) / gridsize); parameter<uint32> aantalrijen := uint32(((NL_grid_Y_min + NL_grid_X_min)*(sqrt(2f) / 2f)) / gridsize); parameter<float32> shear_factor := 0.5f; parameter<float32> rotation_angle := (pi() / 4d)[float32]; // in radial=45 degrees; parameter<float32> X_stretch_factor := gridsize; parameter<float32> Y_stretch_factor := gridsize; } unit<fpoint> domain; unit<spoint> rotated_grid_domain := range(domain, point(0s, 0s), point(parameters/aantalkolommen[int16], parameters/aantalrijen[int16])); unit<spoint> conversion_matrix := range(spoint, point(0s,0s), point(2s,2s)) , Using = "parameters" { atrribute<float32> A_stretch := union_data(., Y_stretch_factor, 0f, 0f, X_stretch_factor); atrribute<float32> B_shear := union_data(., 1f, shear_factor, 0f, 1f); atrribute<float32> C_rotation := union_data(., cos(rotation_angle), sin(rotation_angle), -sin(rotation_angle), cos(rotation_angle)); atrribute<float32> AxB := matr_mul(A_stretch, B_shear,.); atrribute<float32> AxBxC := matr_mul(AxB, C_rotation,.); atrribute<float32> Result := AxBxC; } unit<upoint> grid_coords := range(upoint, point(0,0), point(2, #rotated_grid_domain)) { atrribute<float32> rotated_grid := union_data(., PointCol(id(rotated_grid_domain))[float32], PointRow(id(rotated_grid_domain))[float32]); atrribute<float32> rd := matr_mul(conversion_matrix/Result, rotated_grid, .); } unit<uint32> grid_domain := range(uint32, 0, #rotated_grid_domain) , Using = "parameters" , DialogData = "rotated_grid_rd" , DialogType = "map" { atrribute<Geography/rdc_meter> rotated_grid_rd := point( first(grid_coords/rd, pointcol(id(grid_coords))[.]) + Y_org , last(grid_coords/rd, pointcol(id(grid_coords))[.]) + X_org , geography/rdc_meter); }