Skip to main content

Hello, the workspace is close to “Creating CityGML Solitary Vegetation Object | Community” but without the issues. 
I would like to randomly rotate the instances along the Z axis. Dimensions are set as in the first matrix shown below. When I use the last row to rotate, as shown in the second matrix below, the rotation is ignored and dimensions change. I tried the rotators, and the 3D affiner after defining the matrix to no good results. It seems that CityGML only looks at the transformation matrix.  Any advise or workaround to force instance’s rotation is appreciated. I have a random rotation value stored in an attribute brought as an attribute of the location point. 

+++++ Matrix withOUT rotation +++++++++++

@Value(width) 0.0 0.0 0.0

0.0 @Value(width2) 0.0 0.0

0.0 0.0 @Value(height) 0.0

0.0 0.0 0.0 1.0

+++++ Matrix “WITH” rotation? +++++++++

@Value(width) 0.0 0.0 0.0

0.0 @Value(width2) 0.0 0.0

0.0 0.0 @Value(height) 0.0

0.0 0.0 0.0 @Value(rotation)

 

A rotation matrix looks a bit different: Rotation matrix - Wikipedia

In your case this should work:
@cos(@Value(rotation)) @mult(-1, @sin(@Value(rotation))) 0.0 0.0
@sin(@Value(rotation)) @cos(@Value(rotation))  0.0 0.0
0.0 0.0 @Value(height)  0.0
0.0 0.0 0.0 1.0

 


Hi Max, sorry I was not clear in my question. Yes, I know that is the rotation matrix, but I need to use the transformation matrix also to give height and width and then rotate each randomly. So both transfomrations matrices need to be combined into one which is why I was asking about the last row where I thought rotation could be added. I will try multiplying the two matrices. Your @mult() gave me the idea. Thanks.. I will report if it works. 🤞


Here is an example I use - scale it the scale factor and the other 4 values I’ll explain below 

@Value(1-1) @Value(1-2) 0.0 0.0
@Value(2-1) @Value(1-1) 0.0 0.0
0.0 0.0 @Value(SCALEZ) 0.0
0.0 0.0 0.0 1.0

Rotation angle needs to be in radians e.g.,

((2*@pi())/360)*@Value(ROTATION)

1-1 = 

@Value(SCALEZ)*(@cos(@Value(_radians)))

1-2 = 

@Value(SCALEZ)*(-@sin(@Value(_radians)))

2-1 =

@Value(SCALEZ)*(@sin(@Value(_radians)))

In this case the scale applied is the same strength in each direction.

I think it’s probably easier to do all this stuff with a python caller and numpy.

You can also get it looking correct in FME and then use FME python to extract the transformation matrix from the fme object directly
 


Hi, I have it working now! yeeeeey 😁 . Below is the matrix that worked for me in terms of Matt’s example. 

After converting the angle to radians, I had to  use the mult() function.  Using * for multiplication causes a matrix that is not be properly read when converting to 3D tiles. 

@mult(@Value(SCALEZ),@cos(@Value(_rotatnAngl))) @mult(@Value(SCALEZ),-@sin(@Value(_rotatnAngl))) 0.0 0.0
@mult(@Value(SCALEZ),@sin(@Value(_rotatnAngl))) @mult(@Value(SCALEZ),@cos(@Value(_rotatnAngl))) 0.0 0.0
0.0 0.0 @Value(SCALEZ) 0.0
0.0 0.0 0.0 1.0

I hope this helps others, as well.  Thanks!


Here is an example I use - scale it the scale factor and the other 4 values I’ll explain below 

@Value(1-1) @Value(1-2) 0.0 0.0
@Value(2-1) @Value(1-1) 0.0 0.0
0.0 0.0 @Value(SCALEZ) 0.0
0.0 0.0 0.0 1.0

Rotation angle needs to be in radians e.g.,

((2*@pi())/360)*@Value(ROTATION)

1-1 = 

@Value(SCALEZ)*(@cos(@Value(_radians)))

1-2 = 

@Value(SCALEZ)*(-@sin(@Value(_radians)))

2-1 =

@Value(SCALEZ)*(@sin(@Value(_radians)))

In this case the scale applied is the same strength in each direction.

I think it’s probably easier to do all this stuff with a python caller and numpy.

You can also get it looking correct in FME and then use FME python to extract the transformation matrix from the fme object directly
 

Great solution!