PlanarToMultiBody

model PlanarToMultiBody "This model enables to connect planar models to 3D Models"
    parameter SI.Length zPosition = planarWorld.defaultZPosition "Position z of cylinder representing the fixed translation";
    outer PlanarWorld planarWorld "planar world model";
    Frame_a frame_a "Frame connector in PlanarMechanics"
        annotation (Placement(transformation(extent = {
            {-56, -16}, 
            {-24, 16}})));
    MB.Interfaces.Frame_b frame_b "Frame connector in MultiBody"
        annotation (Placement(transformation(extent = {
            {24, -16}, 
            {56, 16}})));
protected
    SI.Force fz "Normal Force";
    SI.Force f0[3] "Force vector";
equation
    Connections.root(frame_b.R);
    f0 * frame_b.R.T + frame_b.f = zeros(3);
    frame_a.t + MB.Frames.resolve2(planarWorld.R, frame_b.t) * {0, 0, 1} = 0;
    f0 = MB.Frames.resolve1(planarWorld.R, {frame_a.fx, frame_a.fy, fz});
    frame_b.R = MB.Frames.absoluteRotation(planarWorld.R, MB.Frames.planarRotation({0, 0, 1}, frame_a.phi, der(frame_a.phi)));
    frame_b.r_0 = MB.Frames.resolve1(planarWorld.R, {frame_a.x, frame_a.y, zPosition}) + planarWorld.r_0;

    annotation (
        defaultComponentName = "adaptorPlanar2MBS",
        Icon(
            coordinateSystem(
                extent = {
                    {-40, -20}, 
                    {40, 20}},
                preserveAspectRatio = false),
            graphics = {
                Line(
                    points = {
                        {-42, 24}, 
                        {-26, 24}, 
                        {-26, -24}, 
                        {-42, -24}},
                    color = {95, 95, 95},
                    thickness = 0.5), 
                Line(
                    points = {
                        {42, 24}, 
                        {26, 24}, 
                        {26, -24}, 
                        {42, -24}},
                    color = {95, 95, 95},
                    thickness = 0.5), 
                Text(
                    extent = {
                        {-90, 60}, 
                        {90, 30}},
                    textColor = {0, 0, 255},
                    textString = "%name"), 
                Rectangle(
                    extent = {
                        {-26, 8}, 
                        {26, -8}},
                    lineColor = {95, 95, 95},
                    fillColor = {95, 95, 95},
                    fillPattern = FillPattern.Solid)}),
        Documentation(
            revisions = "<html>\n<p>\n<img src=\"modelica://PlanarMechanics/Resources/Images/dlr_logo.png\" alt=\"DLR logo\">\n<strong>Developed 2010 at the DLR Institute of System Dynamics and Control</strong>\n</p>\n</html>",
            info = "<html>\n<p>This component enables the connection between Planarmechanics and <a href=\"Modelica://Modelica.Mechanics.MultiBody\">MultiBody</a>.</p>\n<p>The orientation and position of the 2D system within the 3D system are determined by the Multi-Body connector of the planar world model or zero rotation at zero position otherwise</p>\n<p>The physical connection assumes the 2D world to be the root of the system, defining the orientation. All forces and torques acting outside the plane are assumed to be absorbed by the planar world system.. Beware! These forces are not transmitted by the Multi-Body connector of the planar world.</p>\n</html>"),
        Diagram(
            coordinateSystem(
                extent = {
                    {-40, -20}, 
                    {40, 20}},
                preserveAspectRatio = false),
            graphics = {
                Line(
                    points = {
                        {-40, 0}, 
                        {40, 0}},
                    color = {95, 95, 95},
                    thickness = 0.5)}));
end PlanarToMultiBody;