## API Reference

Detailed and full API reference helps you master Tekla development

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

# MatrixFactoryAddLanguageSpecificTextSet("LST4F0E2470_0?cpp=::|nu=.");ByCoordinateSystems Method

Returns a coordinate transformation matrix defined by two coordinate systems. With the returned matrix points can be transformed from the first coordinate system to the second coordinate system. The ByCoordinateSystems method is meant for transforming points between coordinate systems asked in the same work plane.

Namespace:  Tekla.Structures.Geometry3d
Assembly:  Tekla.Structures (in Tekla.Structures.dll) Version: 2023.0.1
Syntax
```public static Matrix ByCoordinateSystems(
CoordinateSystem CoordSys1,
CoordinateSystem CoordSys2
)```

#### Parameters

CoordSys1
Type: Tekla.Structures.Geometry3dCoordinateSystem
The coordinate system to start from.
CoordSys2
Type: Tekla.Structures.Geometry3dCoordinateSystem
The target coordinate system.

#### Return Value

Type: Matrix
The transformation matrix defined by the two coordinate systems.
Examples
This example shows the beam's extremes in some other model object's 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 the coordinates of the reference model object
private void ShowExtremesInOtherObjectCoordinates(ModelObject ReferenceObject, Beam Beam)
{
//Set the transformation plane to use the beam's coordinate system in order to get the beam's extremes in the local coordinate system
TransformationPlane CurrentTP = _Model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
_Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(Beam.GetCoordinateSystem()));

//Update the beam's extremes to the new transformation plane
Beam.Select();
Point LocalStartPoint = Beam.StartPoint;
Point LocalEndPoint = Beam.EndPoint;

//Get the beam's extremes in the reference object's coordinates
Matrix TransformationMatrix = MatrixFactory.ByCoordinateSystems(Beam.GetCoordinateSystem(), ReferenceObject.GetCoordinateSystem());

//Transform the extreme points to the new coordinate system
Point BeamStartPoint = TransformationMatrix.Transform(LocalStartPoint);
Point BeamEndPoint = TransformationMatrix.Transform(LocalEndPoint);

_Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentTP);

//Transform the points where to show the texts to current work plane coordinate system
Matrix TransformationToCurrent = MatrixFactory.FromCoordinateSystem(ReferenceObject.GetCoordinateSystem());
Point BeamStartPointInCurrent = TransformationToCurrent.Transform(BeamStartPoint);
Point BeamEndPointInCurrent = TransformationToCurrent.Transform(BeamEndPoint);

//Display results
DrawCoordinateSystem(ReferenceObject.GetCoordinateSystem());
GraphicsDrawer.DrawText(BeamStartPointInCurrent, FormatPointCoordinates(BeamStartPoint), TextColor);
GraphicsDrawer.DrawText(BeamEndPointInCurrent, FormatPointCoordinates(BeamEndPoint), 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;
}
}```
See Also