Fixed

model Fixed "Frame fixed in the world frame at a given position"
    import Modelica.Mechanics.MultiBody.Types;
    import Modelica.SIunits.Conversions.to_unit1;

    Interfaces.Frame_b frame_b "Coordinate system fixed in the world frame"
        annotation (Placement(transformation(extent = {
            {84, -16}, 
            {116, 16}})));
    parameter Boolean animation = true "= true, if animation shall be enabled";
    parameter SI.Position r[3] = {0, 0, 0} "Position vector from world frame to frame_b, resolved in world frame";
    parameter Types.ShapeType shapeType = "cylinder" "Type of shape"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    parameter SI.Position r_shape[3] = {0, 0, 0} "Vector from world frame to shape origin, resolved in world frame"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    parameter Types.Axis lengthDirection = to_unit1(r - r_shape) "Vector in length direction of shape, resolved in world frame"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    parameter Types.Axis widthDirection = {0, 1, 0} "Vector in width direction of shape, resolved in world frame"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    parameter SI.Length length = Modelica.Math.Vectors.length(r - r_shape) "Length of shape"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    parameter SI.Distance width = length / world.defaultWidthFraction "Width of shape"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    parameter SI.Distance height = width "Height of shape"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    parameter Types.ShapeExtra extra = 0 "Additional parameter for cone, pipe etc. (see docu of Visualizers.Advanced.Shape)"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    input Types.Color color = Modelica.Mechanics.MultiBody.Types.Defaults.RodColor "Color of shape"
        annotation (Dialog(
            colorSelector = true,
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
    input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient "Reflection of ambient light (= 0: light is completely absorbed)"
        annotation (Dialog(
            tab = "Animation",
            group = "if animation = true",
            enable = animation));
protected
    outer Modelica.Mechanics.MultiBody.World world;
    Visualizers.Advanced.Shape shape(shapeType = shapeType, color = color, specularCoefficient = specularCoefficient, length = length, width = width, height = height, lengthDirection = lengthDirection, widthDirection = widthDirection, extra = extra, r_shape = r_shape, r = zeros(3), R = Frames.nullRotation()) if world.enableAnimation and animation;
equation
    Connections.root(frame_b.R);
    frame_b.R = Frames.nullRotation();
    frame_b.r_0 = r;

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    extent = {
                        {-90, 90}, 
                        {90, -90}},
                    lineColor = {255, 255, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {150, 145}, 
                        {-150, 105}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Line(points = {
                    {0, 100}, 
                    {0, -100}}), 
                Line(points = {
                    {0, -80}, 
                    {-100, -20}}), 
                Line(points = {
                    {0, -40}, 
                    {-100, 20}}), 
                Line(points = {
                    {0, 0}, 
                    {-100, 60}}), 
                Line(points = {
                    {0, 40}, 
                    {-100, 100}}), 
                Line(points = {
                    {0, 0}, 
                    {100, 0}}), 
                Text(
                    extent = {
                        {-150, -105}, 
                        {150, -135}},
                    textString = "r=%r")}),
        Documentation(info = "<html>\n<p>\nElement consisting of a frame (frame_b) that is fixed in the world\nframe at a given position defined by parameter vector <strong>r</strong>\n(vector from origin of world frame to frame_b, resolved in the\nworld frame).\n</p>\n<p>\nBy default, this component is visualized by a cylinder connecting the\nworld frame and frame_b of this components, as shown in the figure below.\nNote, that the visualized world frame on the left side and\nFixed.frame_b on the right side are not part of the\ncomponent animation and that the animation may be switched off via parameter\nanimation = <strong>false</strong>.\n</p>\n<p>\n<img src=\"modelica://Modelica/Resources/Images/Mechanics/MultiBody/Fixed.png\" alt=\"Parts.Fixed\">\n</p>\n\n</html>"),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(points = {
                    {0, 100}, 
                    {0, -100}}), 
                Line(points = {
                    {0, -80}, 
                    {-100, -20}}), 
                Line(points = {
                    {0, -40}, 
                    {-100, 20}}), 
                Line(points = {
                    {0, 0}, 
                    {-100, 60}}), 
                Line(points = {
                    {0, 40}, 
                    {-100, 100}}), 
                Line(points = {
                    {0, 0}, 
                    {100, 0}})}));
end Fixed;