GetRelativeTransformation
The matrix is only given when a unique path through inverse relations can be found,
otherwise the identity matrix is returned.
owlInstanceHead is allowed to be not defined, i.e. zero.
Syntax
public const string enginedll = @"engine.dll"; [DllImport(enginedll, EntryPoint = "GetRelativeTransformation")] public static extern void GetRelativeTransformation(Int64 owlInstanceHead, Int64 owlInstanceTail, out double transformationMatrix); [DllImport(enginedll, EntryPoint = "GetRelativeTransformation")] public static extern void GetRelativeTransformation(Int64 owlInstanceHead, Int64 owlInstanceTail, double[] transformationMatrix);
Property owlInstanceHead
Size: 64 bit / 8 byte (value)Property owlInstanceTail
Size: 64 bit / 8 byte (value)Property transformationMatrix
Size: 32 bit / 4 byte (reference)
Example (based on pure API calls)
Here you can find code snippits that show how the API call GetRelativeTransformation can be used.
using RDF; // include at least engine.cs within your solution static void Main(string[] args) { Int64 model = RDF.engine.CreateModel(); if (model != 0) { // // Classes // Int64 classBox = RDF.engine.GetClassByName(model, "Box"), classMatrix = RDF.engine.GetClassByName(model, "Matrix"), classMatrixMultiplication = RDF.engine.GetClassByName(model, "MatrixMultiplication"), classTransformation = RDF.engine.GetClassByName(model, "Transformation"); // // Object Properties (relations) // Int64 propertyFirstMatrix = RDF.engine.GetPropertyByName(model, "firstMatrix"), propertyMatrix = RDF.engine.GetPropertyByName(model, "matrix"), propertyObject = RDF.engine.GetPropertyByName(model, "object"), propertySecondMatrix = RDF.engine.GetPropertyByName(model, "secondMatrix"); // // Datatype Properties (attributes) // Int64 property_42 = RDF.engine.GetPropertyByName(model, "_42"), propertyLength = RDF.engine.GetPropertyByName(model, "length"), propertyWidth = RDF.engine.GetPropertyByName(model, "width"), propertyHeight = RDF.engine.GetPropertyByName(model, "height"); // // Instances (creating) // Int64 instanceBox = RDF.engine.CreateInstance(classBox, (string) null), instanceMatrixI = RDF.engine.CreateInstance(classMatrix, (string) null), instanceMatrixII = RDF.engine.CreateInstance(classMatrix, (string) null), instanceMatrixIII = RDF.engine.CreateInstance(classMatrix, (string) null), instanceMatrixMultiplication = RDF.engine.CreateInstance(classMatrixMultiplication, (string) null), instanceTransformationI = RDF.engine.CreateInstance(classTransformation, (string) null), instanceTransformationII = RDF.engine.CreateInstance(classTransformation, (string) null); RDF.engine.SetObjectProperty(instanceTransformationI, propertyObject, ref instanceTransformationII, 1); RDF.engine.SetObjectProperty(instanceTransformationI, propertyMatrix, ref instanceMatrixMultiplication, 1); RDF.engine.SetObjectProperty(instanceTransformationII, propertyObject, ref instanceBox, 1); RDF.engine.SetObjectProperty(instanceTransformationII, propertyMatrix, ref instanceMatrixIII, 1); RDF.engine.SetObjectProperty(instanceMatrixMultiplication, propertyFirstMatrix, ref instanceMatrixI, 1); RDF.engine.SetObjectProperty(instanceMatrixMultiplication, propertySecondMatrix, ref instanceMatrixII, 1); double length = 2.8, width = 1.3, height = 1.4; RDF.engine.SetDatatypeProperty(instanceBox, propertyLength, ref length, 1); RDF.engine.SetDatatypeProperty(instanceBox, propertyWidth, ref width, 1); RDF.engine.SetDatatypeProperty(instanceBox, propertyHeight, ref height, 1); // // As a simple case we only apply vertical translation // double verticalTranslationMatrixI = 3.05, verticalTranslationMatrixII = 2.2, verticalTranslationMatrixIII = 7.4; RDF.engine.SetDatatypeProperty(instanceMatrixI, property_42, ref verticalTranslationMatrixI, 1); RDF.engine.SetDatatypeProperty(instanceMatrixII, property_42, ref verticalTranslationMatrixII, 1); RDF.engine.SetDatatypeProperty(instanceMatrixIII, property_42, ref verticalTranslationMatrixIII, 1); RDF.engine.UpdateInstance(instanceTransformationI); double[] transformationMatrix = new double[12]; RDF.engine.GetRelativeTransformation(instanceTransformationI, instanceBox, out transformationMatrix[0]); System.Diagnostics.Debug.Assert(transformationMatrix[3 * 3 + 1] == verticalTranslationMatrixI + verticalTranslationMatrixII + verticalTranslationMatrixIII); RDF.engine.GetRelativeTransformation(instanceTransformationII, instanceBox, out transformationMatrix[0]); System.Diagnostics.Debug.Assert(transformationMatrix[3 * 3 + 1] == verticalTranslationMatrixIII); RDF.engine.GetRelativeTransformation(instanceTransformationI, instanceTransformationII, out transformationMatrix[0]); System.Diagnostics.Debug.Assert(transformationMatrix[3 * 3 + 1] == verticalTranslationMatrixI + verticalTranslationMatrixII); // // The resulting model can be viewed in 3D-Editor.exe // RDF.engine.SaveModel(model, "c:\\created\\myFile.bin"); RDF.engine.CloseModel(model); } }