![]() | MatrixFactoryToCoordinateSystem Method |
Returns a coordinate transformation matrix defined by the given coordinate system.
With the returned matrix points can be transformed from the current work plane coordinate system
to the given coordinate system.
Namespace: Tekla.Structures.Geometry3d
Assembly: Tekla.Structures (in Tekla.Structures.dll) Version: 2023.0.1

Parameters
- CoordSys
- Type: Tekla.Structures.Geometry3dCoordinateSystem
The coordinate system to transform points to.
Return Value
Type: MatrixThe transformation matrix defined by the given coordinate system.

This example shows the extremes of the beam in its local coordinate system.
using System; using System.Globalization; using Tekla.Structures.Geometry3d; using Tekla.Structures.Model; using Tekla.Structures.Model.UI; public class Example { private readonly Model _Model = new Model(); private static GraphicsDrawer GraphicsDrawer = new GraphicsDrawer(); private readonly static Color TextColor = new Color(1, 0, 1); //Shows the beam's extremes in its local coordinates private static void ShowExtremesInBeamLocalCoordinates(Beam Beam) { //Get matrix to transform points to the beam's local coordinate system Matrix TransformationMatrix = MatrixFactory.ToCoordinateSystem(Beam.GetCoordinateSystem()); //Transform the points from current work plane to the local coordinate system Point LocalStartPoint = TransformationMatrix.Transform(Beam.StartPoint); Point LocalEndPoint = TransformationMatrix.Transform(Beam.EndPoint); //Display results DrawCoordinateSystem(Beam.GetCoordinateSystem()); GraphicsDrawer.DrawText(Beam.StartPoint, FormatPointCoordinates(LocalStartPoint), TextColor); GraphicsDrawer.DrawText(Beam.EndPoint, FormatPointCoordinates(LocalEndPoint), TextColor); } //Draws the coordinate system in which the values are shown private static void DrawCoordinateSystem(CoordinateSystem CoordinateSystem) { DrawVector(CoordinateSystem.Origin, CoordinateSystem.AxisX, "X"); DrawVector(CoordinateSystem.Origin, CoordinateSystem.AxisY, "Y"); } //Draws the vector of the coordinate system private static void DrawVector(Point StartPoint, Vector Vector, string Text) { Color Color = new Color(0, 1, 1); const double Radians = 0.43; Vector = Vector.GetNormal(); Vector Arrow01 = new Vector(Vector); Vector.Normalize(500); Point EndPoint = new Point(StartPoint); EndPoint.Translate(Vector.X, Vector.Y, Vector.Z); GraphicsDrawer.DrawLineSegment(StartPoint, EndPoint, Color); GraphicsDrawer.DrawText(EndPoint, Text, Color); Arrow01.Normalize(-100); Vector Arrow = ArrowVector(Arrow01, Radians); Point ArrowExtreme = new Point(EndPoint); ArrowExtreme.Translate(Arrow.X, Arrow.Y, Arrow.Z); GraphicsDrawer.DrawLineSegment(EndPoint, ArrowExtreme, Color); Arrow = ArrowVector(Arrow01, -Radians); ArrowExtreme = new Point(EndPoint); ArrowExtreme.Translate(Arrow.X, Arrow.Y, Arrow.Z); GraphicsDrawer.DrawLineSegment(EndPoint, ArrowExtreme, Color); } //Draws the arrows of the vectors private static Vector ArrowVector(Vector Vector, double Radians) { double X, Y, Z; if(Vector.X == 0 && Vector.Y == 0) { X = Vector.X; Y = (Vector.Y * Math.Cos(Radians)) - (Vector.Z * Math.Sin(Radians)); Z = (Vector.Y * Math.Sin(Radians)) + (Vector.Z * Math.Cos(Radians)); } else { X = (Vector.X * Math.Cos(Radians)) - (Vector.Y * Math.Sin(Radians)); Y = (Vector.X * Math.Sin(Radians)) + (Vector.Y * Math.Cos(Radians)); Z = Vector.Z; } return new Vector(X, Y, Z); } //Shows the point coordinates with only two decimals private static string FormatPointCoordinates(Point Point) { string Output = String.Empty; Output = "(" + Point.X.ToString("0.00", CultureInfo.InvariantCulture) + ", " + Point.Y.ToString("0.00", CultureInfo.InvariantCulture) + ", " + Point.Z.ToString("0.00", CultureInfo.InvariantCulture) + ")"; return Output; } }
