pre-big change
This commit is contained in:
103
vis3d.mo
Normal file
103
vis3d.mo
Normal file
@@ -0,0 +1,103 @@
|
||||
model vis3d
|
||||
import Modelica.Mechanics.MultiBody.Visualizers;
|
||||
import Modelica.Mechanics.MultiBody.Frames;
|
||||
|
||||
parameter Real L = 1;
|
||||
parameter Real w = 0.02;
|
||||
parameter Real orbRadius = 0.04;
|
||||
parameter Real axisLength = 0.25;
|
||||
parameter Real axisWidth = 0.01;
|
||||
|
||||
Modelica.Blocks.Interfaces.RealInput psi annotation(
|
||||
Placement(transformation(origin = {-98, -70}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-94, 20}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput theta annotation(
|
||||
Placement(transformation(origin = {-98, -42}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-94, 50}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput phi annotation(
|
||||
Placement(transformation(origin = {-98, -14}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-94, 80}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput z annotation(
|
||||
Placement(transformation(origin = {-98, 14}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-94, -80}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput y annotation(
|
||||
Placement(transformation(origin = {-98, 42}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-94, -50}, extent = {{-10, -10}, {10, 10}})));
|
||||
Modelica.Blocks.Interfaces.RealInput x annotation(
|
||||
Placement(transformation(origin = {-98, 70}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-94, -20}, extent = {{-10, -10}, {10, 10}})));
|
||||
protected
|
||||
Real R[3,3];
|
||||
Real r[3];
|
||||
|
||||
Visualizers.Advanced.Shape link(
|
||||
shapeType = "cylinder",
|
||||
length = L,
|
||||
width = w,
|
||||
height = w,
|
||||
r_shape = {-L / 2, 0, 0},
|
||||
lengthDirection = {1, 0, 0},
|
||||
widthDirection = {0, 1, 0},
|
||||
r = r,
|
||||
R = Frames.from_T(R, zeros(3)));
|
||||
|
||||
Visualizers.Advanced.Shape orb(
|
||||
shapeType = "sphere",
|
||||
length = 2 * orbRadius,
|
||||
width = 2 * orbRadius,
|
||||
height = 2 * orbRadius,
|
||||
r_shape = {L / 2 - orbRadius, 0, 0},
|
||||
lengthDirection = {1, 0, 0},
|
||||
widthDirection = {0, 1, 0},
|
||||
r = r,
|
||||
R = Frames.from_T(R, zeros(3)));
|
||||
|
||||
Visualizers.Advanced.Shape xAxis(
|
||||
shapeType = "cylinder",
|
||||
length = axisLength,
|
||||
width = axisWidth,
|
||||
height = axisWidth,
|
||||
color = {255, 0, 0},
|
||||
specularCoefficient = 0.1,
|
||||
r_shape = {axisLength / 2, 0, 0},
|
||||
lengthDirection = {1, 0, 0},
|
||||
widthDirection = {0, 1, 0},
|
||||
r = zeros(3),
|
||||
R = Frames.from_T([1, 0, 0;
|
||||
0, 1, 0;
|
||||
0, 0, 1], zeros(3)));
|
||||
|
||||
Visualizers.Advanced.Shape yAxis(
|
||||
shapeType = "cylinder",
|
||||
length = axisLength,
|
||||
width = axisWidth,
|
||||
height = axisWidth,
|
||||
color = {0, 200, 0},
|
||||
specularCoefficient = 0.1,
|
||||
r_shape = {0, axisLength / 2, 0},
|
||||
lengthDirection = {0, 1, 0},
|
||||
widthDirection = {0, 0, 1},
|
||||
r = zeros(3),
|
||||
R = Frames.from_T([1, 0, 0;
|
||||
0, 1, 0;
|
||||
0, 0, 1], zeros(3)));
|
||||
|
||||
Visualizers.Advanced.Shape zAxis(
|
||||
shapeType = "cylinder",
|
||||
length = axisLength,
|
||||
width = axisWidth,
|
||||
height = axisWidth,
|
||||
color = {0, 90, 255},
|
||||
specularCoefficient = 0.1,
|
||||
r_shape = {0, 0, axisLength / 2},
|
||||
lengthDirection = {0, 0, 1},
|
||||
widthDirection = {1, 0, 0},
|
||||
r = zeros(3),
|
||||
R = Frames.from_T([1, 0, 0;
|
||||
0, 1, 0;
|
||||
0, 0, 1], zeros(3)));
|
||||
|
||||
equation
|
||||
r = {x, y, z};
|
||||
R = [cos(psi) * cos(theta), cos(psi) * sin(theta) * sin(phi) - sin(psi) * cos(phi), cos(psi) * sin(theta) * cos(phi) + sin(psi) * sin(phi);
|
||||
sin(psi) * cos(theta), sin(psi) * sin(theta) * sin(phi) + cos(psi) * cos(phi), sin(psi) * sin(theta) * cos(phi) - cos(psi) * sin(phi);
|
||||
-sin(theta), cos(theta) * sin(phi), cos(theta) * cos(phi)];
|
||||
|
||||
annotation(
|
||||
uses(Modelica(version = "4.1.0")),
|
||||
Icon(graphics = {Rectangle(lineColor = {204, 204, 204}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Sphere, extent = {{-100, 100}, {100, -100}}, radius = 10), Text(extent = {{-100, 100}, {100, -100}}, textString = "VIS")}));
|
||||
end vis3d;
|
||||
Reference in New Issue
Block a user