Nevron Forum

angle of rotation

https://www.nevron.com/Forum/Topic5529.aspx

By Laura Monica Ibeas Poch - Tuesday, August 30, 2011

Hello:

I would like to save the shapes of a diagram in a database and later make the diagram from this database. I was thinking to save x, y, width, heigh and angle, but I can´t get this value. How can I do this?

Thank you

 

By Nevron Support - Wednesday, August 31, 2011

Hi,

In order to store the rotation of the shape you need to save the shape's transformation matrix in you database. The transformation matrix stores the rotation, the scaling, the skew and the translation applied to the shape and can be obtained from the shape's Transform property.

By Laura Monica Ibeas Poch - Wednesday, August 31, 2011

I have found it. The GetLengthOrientation method gives me the angle in radians, if I transform it to degrees I can store it in a database. Now, when I create the shape from database, the width is not working ok. I give the location, height and width and then rotate the shape, and it does not work ok. My code:

Dim rect As NShape = factory.CreateShape(BasicShapes.Rectangle)

Dim x As Single = CSng(fila.Item(tbplazas.XColumn.Caption).ToString)

Dim y As Single = CSng(fila.Item(tbplazas.YColumn.Caption).ToString)

Dim ancho As Single = CSng(fila.Item(tbplazas.AnchoColumn.Caption).ToString)

Dim alto As Single = CSng(fila.Item(tbplazas.AltoColumn.Caption).ToString)

Dim angulo As Single = CSng(fila.Item(tbplazas.AnguloColumn.Caption).ToString)

NDrawingDocument1.ActiveLayer.AddChild(rect)

rect.Height = alto

rect.Width = ancho

rect.Location = New NPointF(x, y)

rect.Name = fila.Item(tbplazas.IdColumn.Caption).ToString

rect.Rotate(CoordinateSystem.Scene, angulo, rect.Center)

Why the width is changed after the rotation?

By Laura Monica Ibeas Poch - Thursday, September 1, 2011

Thank you, I stored M11, M12, M21, M22, DX and DY and it seems to work fine.