(sec-module-graphics)= # Module: graphics This module newly introduces revised graphics functions, coherent with Exudyn terminology; it provides basic graphics elements like cuboid, cylinder, sphere, solid of revolution, etc.; offers also some advanced functions for STL import and mesh manipulation; for some advanced functions see graphicsDataUtilties; GraphicsData helper functions generate dictionaries which contain line, text or triangle primitives for drawing in Exudyn using OpenGL. - **Author**: Johannes Gerstmayr - **Date**: 2024-05-10 (created) (sec-graphics-sphere)= ## Function: Sphere [`Sphere(point = [0,0,0], radius = 0.1, color = [0.,0.,0.,1.], nTiles = -1, addEdges = False, edgeColor = color.black, addFaces = True, majorAngleMin = -0.5*pi, majorAngleMax = 0.5*pi, innerRadius = None)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L163) - **function description**: generate graphics data for a sphere with point p and radius; a whole sphere is the type 'Spheres', which the renderer draws as a sphere and the raytracer intersects exactly; with edges, without faces, as a part of a sphere or hollow, it is a 'TriangleList' - **input**: - `point`: center of sphere (3D list or np.array) - `radius`: positive value - `color`: provided as list of 4 RGBA values - `nTiles`: resolution of the sphere, the number of segments of a half circle (>= 2); -1: a whole sphere takes visualizationSettings.general.sphereTiling when it is drawn, the other shapes 8 - `addEdges`: True or number of edges along sphere shell (under development); for optimal drawing, nTiles shall be multiple of 4 or 8 - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges); ignored in case of hollow sphere - `majorAngleMin`: starting angle for sphere to be drawn; if > -0.5*pi, it will be shortened at -Z coordinate - `majorAngleMax`: final angle for sphere to be drawn; if < 0.5*pi, it will be shortened at +Z coordinate - `innerRadius`: draw hollow sphere in case of majorAngleMin or majorAngleMax do not have default values; the outer and the inner sphere and the flat faces at the cuts; a sphere that is not whole consists of 6-node triangles (triangles6) - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ANCFslidingJoint.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFslidingJoint.py) (Ex), [`bicycleIftommBenchmark.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/bicycleIftommBenchmark.py) (Ex), [`bungeeJump.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/bungeeJump.py) (Ex), [`chatGPTupdate.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/chatGPTupdate.py) (Ex), [`contactCurvePolynomial.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/contactCurvePolynomial.py) (Ex), [`connectorGravityTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/connectorGravityTest.py) (TM), [`contactCoordinateTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/contactCoordinateTest.py) (TM), [`contactCurveExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/contactCurveExample.py) (TM), ... (sec-graphics-spheres)= ## Function: Spheres [`Spheres(points, radii = 0.1, colors = [0.,0.,0.,1.], nTiles = -1)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L202) - **function description**: generate graphics data for many spheres at once, as one item of the type 'Spheres' - for particles or point clouds; the renderer draws each as a sphere, the raytracer intersects them exactly - **input**: - `points`: the centers, as a list of 3D points or a numpy array of shape (n,3) - `radii`: one radius for all, or one per point - `colors`: one RGBA color for all, or one per point (list of lists or numpy array of shape (n,4)) - `nTiles`: resolution of the drawn spheres, the number of segments of a half circle (rounded down to a power of 2); -1: visualizationSettings.general.sphereTiling when they are drawn - **output**: graphicsData dictionary {'type':'Spheres', 'points', 'radii', 'colors', 'resolution'} Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`graphicsCurvedShapes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsCurvedShapes.py) (Ex) (sec-graphics-triangles6totriangles)= ## Function: Triangles6ToTriangles [`Triangles6ToTriangles(graphicsData)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L227) - **function description**: convert the 6-node triangles (key 'triangles6') of a TriangleList into 4 flat triangles each, on the same points, and its quadratic edges (key 'edges3') into 2 straight edges each, for the functions that need flat triangles (STL export, ToPointsAndTrigs, ...); the renderer splits them finer, see visualizationSettings.openGL.advanced.curvedTriangleTilingAngle - **input**: - `graphicsData`: a graphicsData dictionary - **output**: a graphicsData dictionary of the type 'TriangleList' with 'triangles' only, or graphicsData itself if it has no 'triangles6' Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`graphicsCurvedShapes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsCurvedShapes.py) (Ex), [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex) (sec-graphics-spherestotrianglelist)= ## Function: SpheresToTriangleList [`SpheresToTriangleList(graphicsData)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L255) - **function description**: convert graphics data of the type 'Spheres' into a 'TriangleList' with the triangles of graphics.Sphere, for the functions that need triangles (merging, STL export, ...); other types are returned unchanged - **input**: - `graphicsData`: a graphicsData dictionary - **output**: a graphicsData dictionary of the type 'TriangleList', or graphicsData itself if it is not of the type 'Spheres' (sec-graphics--spheretriangles6)= ## Function: _SphereTriangles6 [`_SphereTriangles6(point = [0,0,0], radius = 0.1, color = [0.,0.,0.,1.], nTiles = 8, addEdges = False, edgeColor = color.black, addFaces = True, majorAngleMin = -0.5*pi, majorAngleMax = 0.5*pi)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L283) - **function description**: a sphere or a part of it between two latitudes, of 6-node triangles (#2709): nTiles quadratic elements around (the 2*nTiles flat segments of _SphereTriangleList) and ceil(nTiles/2) from majorAngleMin to majorAngleMax, the latitudes and meridians of addEdges as edges3; see Sphere (sec-graphics--spherehollowtriangles6)= ## Function: _SphereHollowTriangles6 [`_SphereHollowTriangles6(point = [0,0,0], radius = 0.1, color = [0.,0.,0.,1.], nTiles = 8, addEdges = False, edgeColor = color.black, majorAngleMin = -0.5*pi, majorAngleMax = 0.5*pi, innerRadius = 0.05)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L328) - **function description**: a hollow sphere between two latitudes, of 6-node triangles (#2709): the outer sphere as _SphereTriangles6, the inner one between the cut planes - or closed where a plane does not reach it -, and the flat faces at the cuts, a ring between the two spheres or a disc where the inner sphere is closed; with addEdges, the circles of the cuts as edges3; see Sphere (sec-graphics--spheretrianglelist)= ## Function: _SphereTriangleList [`_SphereTriangleList(point = [0,0,0], radius = 0.1, color = [0.,0.,0.,1.], nTiles = 8, addEdges = False, edgeColor = color.black, addFaces = True, majorAngleMin = -0.5*pi, majorAngleMax = 0.5*pi)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L390) - **function description**: the flat triangles of a sphere, also a part of a sphere, with edges - for SpheresToTriangleList and RigidLink; see Sphere (sec-graphics-lines)= ## Function: Lines [`Lines(pList, color = [0.,0.,0.,1.], shape = 'linear')`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L507) - **function description**: generate graphics data for a polyline, given by list of points and color; transforms to GraphicsData dictionary - **input**: - `pList`: list of 3D numpy arrays or lists (to achieve closed curve, set last point equal to first point); with shape='quadratic' the points along the curve, each segment by its start point, mid point and end point, so p0, m01, p1, m12, p2, ... - an odd number of points - `color`: provided as list of 4 RGBA values - `shape`: 'linear' for straight segments, 'quadratic' for curved segments, each drawn as a quadratic curve through its three points and split by the renderer, see visualizationSettings.openGL.advanced.curvedTriangleTilingAngle - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects: of the type 'Line' for shape='linear', of the type 'Lines' with shape 'quadratic' else *example*: ```python #create simple 3-point lines gLine=graphics.Lines([[0,0,0],[1,0,0],[2,0.5,0]], color=color.red) #a quarter circle as one quadratic segment gArc=graphics.Lines([[1,0,0],[np.sqrt(0.5),np.sqrt(0.5),0],[0,1,0]], color=color.red, shape='quadratic') ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ANCFcontactCircle2.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFcontactCircle2.py) (Ex), [`ANCFswitchingSlidingJoint2D.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFswitchingSlidingJoint2D.py) (Ex), [`doublePendulum2D.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/doublePendulum2D.py) (Ex), [`graphicsCurvedShapes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsCurvedShapes.py) (Ex), [`lavalRotor2Dtest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/lavalRotor2Dtest.py) (Ex), [`ANCFcontactFrictionTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFcontactFrictionTest.py) (TM), [`ANCFmovingRigidBodyTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFmovingRigidBodyTest.py) (TM), [`ANCFslidingAndALEjointTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFslidingAndALEjointTest.py) (TM), ... (sec-graphics-circle)= ## Function: Circle [`Circle(point = [0,0,0], radius = 1, color = [0.,0.,0.,1.])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L543) - **function description**: generate graphics data for a single circle; currently the plane normal = [0,0,1], just allowing to draw planar circles -- this may be extended in future! - **input**: - `point`: center point of circle - `radius`: radius of circle - `color`: provided as list of 4 RGBA values - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects - **notes**: the tiling (number of segments to draw circle) can be adjusted by visualizationSettings.general.circleTiling Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ANCFcontactCircle2.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFcontactCircle2.py) (Ex) (sec-graphics-text)= ## Function: Text [`Text(point = [0,0,0], text = '', color = [0.,0.,0.,1.], fontSize = 0., offset = [0.,0.])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L561) - **function description**: generate graphics data for a text drawn at a 3D position - **input**: - `point`: position of text - `text`: string representing text; multiline texts can be written with line breaks - `color`: provided as list of 4 RGBA values - `fontSize`: scalar fontSize or 0. for default; default font size in Exudyn is 12 (visualizationSettings.view0.window.globalFontSize) - `offset`: offset in X/Y screen plane provided as list of 2 float values; this offset is not rotated with the model view and given relative to font size (offset [1,1] equals to offset of one character moved right and up) - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects - **notes**: text size can be adjusted with visualizationSettings.view0.window.globalFontSize, which affects the text size (=font size) globally Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ANCFcontactCircle2.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFcontactCircle2.py) (Ex), [`NGsolveGeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveGeometry.py) (Ex), [`raytracerNOGLFWtest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/raytracerNOGLFWtest.py) (TM) (sec-graphics-cuboid)= ## Function: Cuboid [`Cuboid(pList, color = [0.,0.,0.,1.], faces = [1,1,1,1,1,1], addNormals = False, addEdges = False, edgeColor = color.black, addFaces = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L586) - **function description**: generate graphics data for general block with endpoints, according to given vertex definition - **input**: - `pList`: is a list of points [[x0,y0,z0],[x1,y1,z1],...] - `color`: provided as list of 4 RGBA values - `faces`: includes the list of six binary values (0/1), denoting active faces (value=1); set index to zero to hide face - `addNormals`: if True, normals are added and there are separate points for every triangle - `addEdges`: if True, edges are added in TriangleList of GraphicsData - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects (sec-graphics-brickxyz)= ## Function: BrickXYZ [`BrickXYZ(xMin, yMin, zMin, xMax, yMax, zMax, color = [0.,0.,0.,1.], addNormals = False, addEdges = False, edgeColor = color.black, addFaces = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L687) - **function description**: generate graphics data for orthogonal 3D block with min and max dimensions - **input**: x/y/z/Min/Max: minimal and maximal cartesian coordinates for orthogonal cube color: list of 4 RGBA values addNormals: add face normals to triangle information addEdges: if True, edges are added in TriangleList of GraphicsData edgeColor: optional color for edges addFaces: if False, no faces are added (only edges) - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects - **notes**: DEPRECATED Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`rigidRotor3DbasicBehaviour.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/rigidRotor3DbasicBehaviour.py) (Ex), [`rigidRotor3DFWBW.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/rigidRotor3DFWBW.py) (Ex), [`rigidRotor3Drunup.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/rigidRotor3Drunup.py) (Ex), [`slidercrankWithMassSpring.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/slidercrankWithMassSpring.py) (Ex), [`libraryDeprecationTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/libraryDeprecationTest.py) (TM), [`sliderCrank3Dbenchmark.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/sliderCrank3Dbenchmark.py) (TM), [`sliderCrank3Dtest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/sliderCrank3Dtest.py) (TM), [`sliderCrankFloatingTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/sliderCrankFloatingTest.py) (TM), ... (sec-graphics-brick)= ## Function: Brick [`Brick(centerPoint = [0,0,0], size = [0.1,0.1,0.1], color = [0.,0.,0.,1.], addNormals = False, addEdges = False, edgeColor = color.black, addFaces = True, roundness = 0, nTiles = 12)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L711) - **function description**: generate graphics data for orthogonal 3D box with center point and size; using roundness=1, it draws an ellipsoid inside the box and in case 0 < roundness < 1, it draws a body blended between box and ellipsoid - **input**: - `centerPoint`: center of box as 3D list or np.array - `size`: size as 3D list or np.array - `color`: list of 4 RGBA values - `addNormals`: add face normals to triangle information - `addEdges`: if True, edges are added in TriangleList of GraphicsData - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - `roundness`: if > 0, it draws an ellipsoid, using nTiles for drawing; edges are not available if roundness > 0 - `nTiles`: only apply if roundness > 0; discretization of whole ellipsoid; should be multiple of 4 to avoid artifacts - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects; if addEdges=True, it returns a list of two dictionaries Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`addPrismaticJoint.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/addPrismaticJoint.py) (Ex), [`addRevoluteJoint.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/addRevoluteJoint.py) (Ex), [`ANCFrotatingCable2D.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFrotatingCable2D.py) (Ex), [`ANCFslidingJoint.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFslidingJoint.py) (Ex), [`ballBearningModel.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ballBearningModel.py) (Ex), [`ballBearingTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ballBearingTest.py) (TM), [`bricardMechanism.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/bricardMechanism.py) (TM), [`carRollingDiscTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/carRollingDiscTest.py) (TM), ... (sec-graphics--quadraticpatch)= ## Function: _QuadraticPatch [`_QuadraticPatch(PointAndNormal, nu, nv, closedU, closedV, offset = 0)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L826) - **function description**: 6-node triangles on a parametric patch (#2709): nu x nv quadratic elements, PointAndNormal(u, v) with u, v in [0,1] gives a point and its (outward) normal; the grid holds the corners and the mid nodes of the elements, (2nu (+1)) x (2nv (+1)) points; each element is two 6-node triangles, oriented so that their corners turn counterclockwise about the given normals. Returns (points, normals, triangles6, Index), Index(i, j) the number of the grid point i (along u) and j (along v), plus offset (sec-graphics--orienttriangle6)= ## Function: _OrientTriangle6 [`_OrientTriangle6(t, points, normal)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L872) - **function description**: the 6-node triangle t with its corners turned counterclockwise about normal (sec-graphics--orienttriangle)= ## Function: _OrientTriangle [`_OrientTriangle(t, points, normal)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L880) - **function description**: the flat triangle t with its corners turned counterclockwise about normal (sec-graphics--numberofquadraticelements)= ## Function: _NumberOfQuadraticElements [`_NumberOfQuadraticElements(nSegments)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L888) - **function description**: the quadratic elements that replace nSegments flat segments: each covers two of them (#2709) (sec-graphics-cylinder)= ## Function: Cylinder [`Cylinder(pAxis = [0,0,0], vAxis = [0,0,1], radius = 0.1, color = [0.,0.,0.,1.], nTiles = 16, radiusInner = None, angleRange = [0,2*pi], lastFace = True, cutPlain = True, addEdges = False, edgeColor = color.black, addFaces = True, **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L893) - **function description**: generate graphics data for a cylinder with given axis, radius and color; nTiles gives the number of tiles (minimum=3); the cylinder consists of 6-node triangles (triangles6), ceil(nTiles/2) curved elements around, drawn with at least nTiles segments - **input**: - `pAxis`: axis point of one face of cylinder (3D list or np.array) - `vAxis`: vector representing the cylinder's axis (3D list or np.array) - `radius`: positive value representing radius of cylinder - `color`: provided as list of 4 RGBA values - `nTiles`: used to determine resolution of cylinder >=3; use larger values for finer resolution - `radiusInner`: if not equal 0, this represents the inner radius of a hollow cylinder; some options like angleRange, lastFace, etc. do not work in this case - `angleRange`: given in rad, to draw only part of cylinder (halfcylinder, etc.); for full range use [0..2 * pi] - `lastFace`: if angleRange != [0,2*pi], then the faces of the open cylinder are shown with lastFace = True - `cutPlain`: only used for angleRange != [0,2*pi]; if True, a plane is cut through the part of the cylinder; if False, the cylinder becomes a cake shape ... - `addEdges`: if True, edges are added in TriangleList of GraphicsData; if addEdges is integer, additional int(addEdges) lines are added on the cylinder mantle - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - `alternatingColor`: if given, optionally another color in order to see rotation of solid; only works, if angleRange=[0,2*pi] - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ANCFslidingJoint.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFslidingJoint.py) (Ex), [`beltDriveALE.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/beltDriveALE.py) (Ex), [`beltDriveReevingSystem.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/beltDriveReevingSystem.py) (Ex), [`beltDrivesComparison.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/beltDrivesComparison.py) (Ex), [`bicycleIftommBenchmark.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/bicycleIftommBenchmark.py) (Ex), [`ANCFbeltDrive.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFbeltDrive.py) (TM), [`ANCFgeneralContactCircle.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFgeneralContactCircle.py) (TM), [`coordinateSpringDamperExt.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/coordinateSpringDamperExt.py) (TM), ... (sec-graphics-tube)= ## Function: Tube [`Tube(points, axes, radius = 0.1, color = [0.,0.,0.,1.], nTiles = 16)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1049) - **function description**: generate graphics data for a tube with given list of points and axes, radius and color; nTiles gives the number of tiles (minimum=3) - **input**: - `points`: list of 3D vectors (or numpy arrays) representing the center points of the tube line - `axes`: list of 3D vectors (or numpy arrays) representing the axis according to the points - `radius`: positive value representing radius of tube - `color`: provided as list of 4 RGBA values - `nTiles`: used to determine resolution of cylinder >=3; use larger values for finer resolution; the tube consists of 6-node triangles (triangles6), ceil(nTiles/2) curved elements around, drawn with at least nTiles segments - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects (sec-graphics-torus)= ## Function: Torus [`Torus(point, axis, radiusMajor = 0.5, radiusMinor = 0.1, color = [0., 0., 0., 1.], nTilesMajor = 24, nTilesMinor = 12, minorAngleStart = 0, minorAngleEnd = 2*np.pi, smoothNormals = True, invert = False)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1134) - **function description**: generate graphics data for a torus with given major and minor radius, center point and axis - **input**: - `point`: 3D vector (or numpy array) representing the center point of the torus - `axis`: 3D vector (or numpy array) representing the axis of revolution of the torus - `radiusMajor`: major radius of torus - `radiusMinor`: minor radius of torus - `color`: provided as list of 4 RGBA values - `nTilesMajor`: used to for resolution of tube with major radius; use larger values for finer resolution - `nTilesMinor`: used to for resolution of circle with minor radius; use larger values for finer resolution - `minorAngleStart`: starting angle for minor radius; 0 is the angle at outmost radius of torus, pi is at inside - `minorAngleEnd`: end angle for minor radius; use -0.5*pi / 0.5*pi to draw only the outer half of the torus - `smoothNormals`: if True, the torus consists of 6-node triangles (triangles6), ceil(nTilesMajor/2) x ceil(nTilesMinor/2) curved elements, drawn with at least the given numbers of segments; otherwise of flat triangles - `invert`: if False, the outside faces are visible; if invert=True, the inside faces are visible (influences reflections, light, etc.) - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`graphicsCurvedShapes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsCurvedShapes.py) (Ex) (sec-graphics-rigidlink)= ## Function: RigidLink [`RigidLink(p0, p1, axis0 = [0,0,0], axis1 = [0,0,0], radius = [0.1,0.1], thickness = 0.05, width = [0.05,0.05], color = [0.,0.,0.,1.], nTiles = 16)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1239) - **function description**: generate graphics data for a planar Link between the two joint positions, having two axes - **input**: - `p0`: joint0 center position - `p1`: joint1 center position - `axis0`: direction of rotation axis at p0, if drawn as a cylinder; [0,0,0] otherwise - `axis1`: direction of rotation axis of p1, if drawn as a cylinder; [0,0,0] otherwise - `radius`: list of two radii [radius0, radius1], being the two radii of the joints drawn by a cylinder or sphere - `width`: list of two widths [width0, width1], being the two widths of the joints drawn by a cylinder; ignored for sphere - `thickness`: the thickness of the link (shaft) between the two joint positions; thickness in z-direction or diameter (cylinder) - `color`: provided as list of 4 RGBA values - `nTiles`: used to determine resolution of cylinder >=3; use larger values for finer resolution - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`fourBarMechanism3D.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/fourBarMechanism3D.py) (Ex), [`geneticOptimizationSliderCrank.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/geneticOptimizationSliderCrank.py) (Ex), [`multiMbsTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/multiMbsTest.py) (Ex), [`pistonEngine.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/pistonEngine.py) (Ex), [`sliderCrank3DwithANCFbeltDrive2.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/sliderCrank3DwithANCFbeltDrive2.py) (Ex), [`fourBarMechanismIftomm.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/fourBarMechanismIftomm.py) (TM), [`rollingDiscTangentialForces.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/rollingDiscTangentialForces.py) (TM), [`sliderCrank3Dbenchmark.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/sliderCrank3Dbenchmark.py) (TM), ... (sec-graphics-solidofrevolution)= ## Function: SolidOfRevolution [`SolidOfRevolution(pAxis, vAxis, contour, color = [0.,0.,0.,1.], nTiles = 16, smoothContour = False, addEdges = False, edgeColor = color.black, addFaces = True, smoothingAngle = 2*np.pi, **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1288) - **function description**: generate graphics data for a solid of revolution with given 3D point and axis, 2D point list for contour, (optional)2D normals and color; - **input**: - `pAxis`: axis point of one face of solid of revolution (3D list or np.array) - `vAxis`: vector representing the solid of revolution's axis (3D list or np.array) - `contour`: a list of 2D-points, specifying the contour (x=axis, y=radius), e.g.: [[0,0],[0,0.1],[1,0.1]] - `color`: provided as list of 4 RGBA values - `nTiles`: used to determine resolution of solid; use larger values for finer resolution; the solid consists of 6-node triangles (triangles6), ceil(nTiles/2) curved elements around, drawn with at least nTiles segments - `smoothContour`: if True, the contour is made smooth by auto-computing normals to the contour - `addEdges`: True or number of edges along revolution mantle; for optimal drawing, nTiles shall be multiple addEdges - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - `smoothingAngle`: if angle between two edges is smaller than smoothingAngle, smoothing is applied - `alternatingColor`: add a second color, which enables to see the rotation of the solid - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects *example*: ```python #simple contour, using list of 2D points: contour=[[0,0.2],[0.3,0.2],[0.5,0.3],[0.7,0.4],[1,0.4],[1,0.]] rev1 = graphics.SolidOfRevolution(pAxis=[0,0.5,0], vAxis=[1,0,0], contour=contour, color=color.red, alternatingColor=color.grey) #draw torus: contour=[] r = 0.2 #small radius of torus R = 0.5 #big radius of torus nc = 16 #discretization of torus for i in range(nc+3): #+3 in order to remove boundary effects contour+=[[r*cos(i/nc*pi*2),R+r*sin(i/nc*pi*2)]] #use smoothContour to make torus looking smooth rev2 = graphics.SolidOfRevolution(pAxis=[0,0.5,0], vAxis=[1,0,0], contour=contour, color=color.red, nTiles = 64, smoothContour=True) ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ballBearningModel.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ballBearningModel.py) (Ex), [`graphicsCurvedShapes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsCurvedShapes.py) (Ex), [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex), [`gyroStability.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/gyroStability.py) (Ex), [`involuteGearGraphics.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/involuteGearGraphics.py) (Ex), [`ballBearingTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ballBearingTest.py) (TM), [`ConvexContactTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ConvexContactTest.py) (TM), ... (sec-graphics-arrow)= ## Function: Arrow [`Arrow(pAxis, vAxis, radius, color = [0.,0.,0.,1.], headFactor = 2, headStretch = 4, nTiles = 12)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1442) - **function description**: generate graphics data for an arrow with given origin, axis, shaft radius, optional size factors for head and color; nTiles gives the number of tiles (minimum=3) - **input**: - `pAxis`: axis point of the origin (base) of the arrow (3D list or np.array) - `vAxis`: vector representing the vector pointing from the origin to the tip (head) of the error (3D list or np.array) - `radius`: positive value representing radius of shaft cylinder - `headFactor`: positive value representing the ratio between head's radius and the shaft radius - `headStretch`: positive value representing the ratio between the head's radius and the head's length - `color`: provided as list of 4 RGBA values - `nTiles`: used to determine resolution of arrow (of revolution object) >=3; use larger values for finer resolution - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`beltDriveALE.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/beltDriveALE.py) (Ex), [`beltDriveReevingSystem.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/beltDriveReevingSystem.py) (Ex), [`beltDrivesComparison.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/beltDrivesComparison.py) (Ex), [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex), [`reevingSystem.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/reevingSystem.py) (Ex), [`ACFtest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ACFtest.py) (TM), [`ANCFbeltDrive.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFbeltDrive.py) (TM), [`ANCFgeneralContactCircle.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFgeneralContactCircle.py) (TM), ... (sec-graphics-basis)= ## Function: Basis [`Basis(origin = [0,0,0], rotationMatrix = np.eye(3), length = 1, colors = [color.red, color.green, color.blue], headFactor = 2, headStretch = 4, nTiles = 12, **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1464) - **function description**: generate graphics data for three arrows representing an orthogonal basis with point of origin, shaft radius, optional size factors for head and colors; nTiles gives the number of tiles (minimum=3) - **input**: - `origin`: point of the origin of the base (3D list or np.array) - `rotationMatrix`: optional transformation, which rotates the basis vectors - `length`: positive value representing lengths of arrows for basis - `colors`: provided as list of 3 colors (list of 4 RGBA values) - `headFactor`: positive value representing the ratio between head's radius and the shaft radius - `headStretch`: positive value representing the ratio between the head's radius and the head's length - `nTiles`: used to determine resolution of arrows of basis (of revolution object) >=3; use larger values for finer resolution - `radius`: positive value representing radius of arrows; default: radius = 0.01*length - `labels`: a list of 3 strings written to the three axes (X, Y, Z); in this case, the result is returned as list of GraphicsData! - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ballBearningModel.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ballBearningModel.py) (Ex), [`camFollowerExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/camFollowerExample.py) (Ex), [`fourBarMechanism3D.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/fourBarMechanism3D.py) (Ex), [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex), [`gyroStability.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/gyroStability.py) (Ex), [`ballBearingTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ballBearingTest.py) (TM), [`bricardMechanism.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/bricardMechanism.py) (TM), [`contactCurveExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/contactCurveExample.py) (TM), ... (sec-graphics-frame)= ## Function: Frame [`Frame(HT = np.eye(4), length = 1, colors = [color.red, color.green, color.blue], headFactor = 2, headStretch = 4, nTiles = 12, **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1505) - **function description**: generate graphics data for frame (similar to Basis), showing three arrows representing an orthogonal basis for the homogeneous transformation HT; optional shaft radius, optional size factors for head and colors; nTiles gives the number of tiles (minimum=3) - **input**: - `HT`: homogeneous transformation representing frame - `length`: positive value representing lengths of arrows for basis - `colors`: provided as list of 3 colors (list of 4 RGBA values) - `headFactor`: positive value representing the ratio between head's radius and the shaft radius - `headStretch`: positive value representing the ratio between the head's radius and the head's length - `nTiles`: used to determine resolution of arrows of basis (of revolution object) >=3; use larger values for finer resolution - `radius`: positive value representing radius of arrows; default: radius = 0.01*length - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`serialRobotInverseKinematics.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotInverseKinematics.py) (Ex) (sec-graphics-quad)= ## Function: Quad [`Quad(pList, color = [0.,0.,0.,1.], **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1537) - **function description**: generate graphics data for simple quad with option for checkerboard pattern; points are arranged counter-clock-wise, e.g.: p0=[0,0,0], p1=[1,0,0], p2=[1,1,0], p3=[0,1,0] - **input**: - `pList`: list of 4 quad points [[x0,y0,z0],[x1,y1,z1],...] - `color`: provided as list of 4 RGBA values - `alternatingColor`: second color; if defined, a checkerboard pattern (default: 10x10) is drawn with color and alternatingColor - `nTiles`: number of tiles for checkerboard pattern (default: 10) - `nTilesY`: if defined, use number of tiles in y-direction different from x-direction (=nTiles) - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects *example*: ```python plane = graphics.Quad([[-8, 0, -8],[ 8, 0, -8,],[ 8, 0, 8],[-8, 0, 8]], color.darkgrey, nTiles=8, alternatingColor=color.lightgrey) oGround=mbs.AddObject(ObjectGround(referencePosition=[0,0,0], visualization=VObjectGround(graphicsData=[plane]))) ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`massSpringFrictionInteractive.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/massSpringFrictionInteractive.py) (Ex), [`nMassOscillator.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/nMassOscillator.py) (Ex), [`nMassOscillatorEigenmodes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/nMassOscillatorEigenmodes.py) (Ex), [`nMassOscillatorInteractive.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/nMassOscillatorInteractive.py) (Ex), [`simulateInteractively.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/simulateInteractively.py) (Ex), [`sphereTriangleTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/sphereTriangleTest.py) (TM), ... (sec-graphics-checkerboard)= ## Function: CheckerBoard [`CheckerBoard(point = [0,0,0], normal = [0,0,1], size = 1, color = color.lightgrey, alternatingColor = color.lightgrey2, nTiles = 10, **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1616) - **function description**: function to generate checkerboard background; points are arranged counter-clock-wise, e.g.: - **input**: - `point`: midpoint of pattern provided as list or np.array - `normal`: normal to plane provided as list or np.array - `size`: dimension of first side length of quad - `size2`: dimension of second side length of quad - `color`: provided as list of 4 RGBA values - `alternatingColor`: second color; if defined, a checkerboard pattern (default: 10x10) is drawn with color and alternatingColor - `nTiles`: number of tiles for checkerboard pattern in first direction - `nTiles2`: number of tiles for checkerboard pattern in second direction; default: nTiles - `materialIndex`: use special graphics material for both colors - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects *example*: ```python plane = graphics.CheckerBoard(normal=[0,0,1], size=5) oGround=mbs.AddObject(ObjectGround(referencePosition=[0,0,0], visualization=VObjectGround(graphicsData=[plane]))) ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ANCFrotatingCable2D.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFrotatingCable2D.py) (Ex), [`ANCFslidingJoint.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ANCFslidingJoint.py) (Ex), [`ballBearningModel.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ballBearningModel.py) (Ex), [`bicycleIftommBenchmark.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/bicycleIftommBenchmark.py) (Ex), [`camFollowerExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/camFollowerExample.py) (Ex), [`ANCFoutputTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ANCFoutputTest.py) (TM), [`ballBearingTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ballBearingTest.py) (TM), [`bricardMechanism.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/bricardMechanism.py) (TM), ... (sec-graphics-solidextrusion)= ## Function: SolidExtrusion [`SolidExtrusion(vertices, segments, height, rot = np.diag([1,1,1]), pOff = [0,0,0], relRot = np.diag([1,1,1]), relOff = [0,0,0], color = [0,0,0,1], smoothNormals = False, addEdges = False, edgeColor = color.black, addFaces = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1665) - **function description**: create graphicsData for solid extrusion based on 2D points and segments; by default, the extrusion is performed in z-direction; additional transformations are possible to translate and rotate the extruded body; - **input**: - `vertices`: list of pairs of coordinates of vertices in mesh [x,y], see ComputeTriangularMesh(...) - `segments`: list of segments, which are pairs of node numbers [i,j], defining the boundary of the mesh; the ordering of the nodes is such that left triangle = inside, right triangle = outside; see ComputeTriangularMesh(...) - `height`: height of extruded object - `rot`: rotation matrix, which the whole extruded object point coordinates are multiplied with before adding offset - `pOff`: 3D offset vector added to all extruded coordinates (both planes); the z-coordinate of the extrusion object obtains 0 for the base plane, z=height for the top plane - `relRot`: rotation matrix for transformation of top (second) plane of extrusion object - `relOff`: 3D offset vector added top (second) plane of extrusion object; the z-coordinate is added to height, which is the base z-value - `color`: provided as list of 4 RGBA values - `smoothNormals`: if True, algorithm tries to smoothen normals at vertices and normals are added; creates more points; if False, triangle normals are used internally - `addEdges`: if True or 1, edges at bottom/top are included in the GraphicsData dictionary; if 2, also mantle edges are included - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - **output**: graphicsData dictionary, to be used in visualization of EXUDYN objects *example*: ```python #simple block with cutout g = graphics.SolidExtrusion(vertices=[[-0.4,-0.4], [0.4,-0.4], [ 0.4,0.4], [0.1,0.4], [0.1, 0.2], [-0.1,0.2], [-0.1,0.4], [-0.4,0.4]], segments=[[0,1], [1,2], [2,3], [3,4], [4,5], [5,6], [6,7], [7,0]], pOff = [0,2,-1], height=1.5, color=graphics.color.steelblue, addEdges=2) oGround=mbs.CreateGround(graphicsDataList=[g]) ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`chainDriveExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/chainDriveExample.py) (Ex), [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex), [`simulatorCouplingTwoMbs.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/simulatorCouplingTwoMbs.py) (TM) (sec-graphics-linkedcylinders)= ## Function: LinkedCylinders [`LinkedCylinders(point0, point1, axisCylinder, radius0, radius1, radiusInner0 = 0, radiusInner1 = 0, nTiles = 32, color = [0,0,0,1], addEdges = 0, edgeColor = color.black, addFaces = True, smoothNormals = True, **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1813) - **function description**: generate graphics data for an extrusion solid linking two circles by their external tangents in a plane; the shape is extruded along axisCylinder with height equal to its norm; nTiles controls circle tessellation - **input**: - `point0`: center of the first circle and base point of the extrusion (3D list or np.array) - `point1`: a point whose projection into the plane through point0 with normal axisCylinder defines the direction to the second circle center (3D list or np.array) - `axisCylinder`: vector normal to the circle plane and extrusion direction; extrusion height is ||axisCylinder|| (3D list or np.array) - `radius0`: radius of the first circle (positive float) - `radius1`: radius of the second circle (positive float) - `radiusInner0`: if > 0, radius of bore of the first circle - `radiusInner1`: if > 0, radius of bore of the second circle - `nTiles`: tiling used for a full circle (>=3); partial arcs are sampled proportionally - `color`: provided as list of 4 RGBA values - `addEdges`: if True, edges are added in TriangleList of GraphicsData; if addEdges is integer, additional int(addEdges) lines are added on the extrusion - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - `smoothNormals`: if True, algorithm tries to smoothen normals at vertices and normals are added; creates more points; if False, triangle normals are used internally - `kwargs`: forwarded to graphics.SolidExtrusion - **output**: graphicsData dictionary, to be used in visualization of Exudyn objects *example*: ```python g = graphics.LinkedCylinders(point0=[0,0,0], point1=[0.8,0.2,0.4], axisCylinder=[0,0,1.2], radius0=0.25, radius1=0.15, nTiles=48, color=graphics.color.steelblue, addEdges=2) oGround=mbs.CreateGround(graphicsDataList=[g]) ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`graphicsCurvedShapes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsCurvedShapes.py) (Ex) (sec-graphics--linkedcylindersflat)= ## Function: _LinkedCylindersFlat [`_LinkedCylindersFlat(c1, radius0, radius1, theta, radiusInner0, radiusInner1, nTiles, p0, rot, height, color, addEdges, edgeColor, addFaces, smoothNormals, **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L1994) - **function description**: LinkedCylinders as flat extrusion (SolidExtrusion), for the arguments that only SolidExtrusion takes (sec-graphics-ballbearingrings)= ## Function: BallBearingRings [`BallBearingRings(axis, outsideDiameter, boreDiameter, width, radiusCage, innerRingShoulderRadius, outerRingShoulderRadius, widthCage, heightCage, innerEdgeChamfer, outerEdgeChamfer, innerGrooveRadius, outerGrooveRadius, innerGrooveTorusRadius, outerGrooveTorusRadius, nTilesRings = 32, nTilesGrooves = 12, colorCage = [0.6,0.5,0.5,0.4], colorInnerRing = [0.5,0.5,0.5,0.5], colorOuterRing = [0.5,0.5,0.5,0.5], **kwargs)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2063) - **function description**: generate graphics for ball bearing rings, in particular for inner and outer rings; note that base parameters are identical as in function GetBallBearingData, assuming that the dictionary of the latter function is used as input for BallBearingRings - **input**: - `innerGrooveTorusRadius`: major radius of torus for inner groove - `outerGrooveTorusRadius`: major radius of torus for outer groove - `nTilesRings`: circumferential tiling of rings - `nTilesGrooves`: tiling of grooves - `colorCage`: cage RGBA color - `colorInnerRing`: inner ring RGBA color - `colorOuterRing`: outer ring RGBA color - **output**: dictionary of graphics data containing 'innerRingGraphics', 'outerRingGraphics' and 'cageGraphics'; Note: graphics data is in the local bearing coordinate system, which should align with inner ring, outer ring and cage bodies! *example*: ```python import exudyn.graphics as graphics from machines import GetBallBearingData data = GetBallBearingData(axis=[0,0,1], outsideDiameter=0.080, boreDiameter=0.050, width=0.010, nBalls=12) graphicsData = graphics.BallBearingRings(**data) #... graphicsData now contains graphics of rings ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ballBearningModel.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ballBearningModel.py) (Ex), [`ballBearingTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/ballBearingTest.py) (TM) (sec-graphics-involutegear)= ## Function: InvoluteGear [`InvoluteGear(involuteGear, width, centerPoint = np.zeros(3), rotationMatrix = np.eye(3), helixAngleDeg = 0, radius = 0, relativeAngleOffset = 0, color = [0,0,0,1], nTilesCylinder = 32, smoothNormals = False, addEdges = False, edgeColor = color.black, addFaces = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2169) - **function description**: create graphics for involute gear, using data from machines.InvoluteGear - **input**: - `involuteGear`: an instance of the class machines.InvoluteGear, containing gear data - `width`: width of gear - `centerPoint`: used to shift the center point of the gear; if 0, the center is in the middle of the gear - `rotationMatrix`: the gear is constructed in the x-y plane, with the gear axis [0,0,1]; to get any other axis, provide the rotation matrix - `helixAngleDeg`: optional angle for helix gears in degree; note that this is only an approximation to real helical gear geometry! - `radius`: in case of internal gear, this is the outer radius; for regular gear, this is the bore radius - `relativeAngleOffset`: angular offset (about gear wheel axis) relative to the angle of one tooth and gap; 0.5 means that the tooth goes to the position of the gap - `color`: provided as list of 4 RGBA values - `smoothNormals`: if True, algorithm tries to smoothen normals at vertices and normals are added; creates more points; if False, triangle normals are used internally - `addEdges`: if True or 1, edges at bottom/top are included in the GraphicsData dictionary; if 2, also mantle edges are included - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - **output**: single graphics data for gear Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`involuteGearGraphics.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/involuteGearGraphics.py) (Ex) (sec-graphics-toothedrack)= ## Function: ToothedRack [`ToothedRack(module, nTeeth, width, toothHeight, rackBaseHeight, pressureAngleDeg = 20, centerPoint = np.zeros(3), rotationMatrix = np.eye(3), color = [0,0,0,1], nTilesCylinder = 32, addEdges = False, edgeColor = color.black, addFaces = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2231) - **function description**: create graphics for toothed rack - **input**: - `module`: the module in m; thus, m*pi represents the mid-distance of one tooth to the next one - `width`: width of gear - `nTeeth`: number of teeth used; this gives the length; if this is a float number, only part of the last root or tooth are drawn accordingly - `toothHeight`: height of tooth from root to head - `rackBaseHeight`: height of rack below root - `pressureAngleDeg`: pressure angle in degree for tooth shape - `centerPoint`: used to shift the center point of the gear; if 0, the center is at the start point of the generated toothed rack (x=0,y=0), z=0 is in the middle of the rack - `rotationMatrix`: the gear is constructed in the x-y plane, with width along z-axis - `color`: provided as list of 4 RGBA values - `smoothNormals`: if True, algorithm tries to smoothen normals at vertices and normals are added; creates more points; if False, triangle normals are used internally - `addEdges`: if True or 1, edges at bottom/top are included in the GraphicsData dictionary; if 2, also mantle edges are included - `edgeColor`: optional color for edges - `addFaces`: if False, no faces are added (only edges) - **output**: single graphics data for gear Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`involuteGearGraphics.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/involuteGearGraphics.py) (Ex) (sec-graphics-boundingboxsingle)= ## Function: BoundingBoxSingle [`BoundingBoxSingle(graphicsData)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2301) - **function description**: compute bounding box of single graphicsData - **input**: - `graphicsData`: a single Exudyn GraphicsData object - **output**: (type: list) [bmin, bmax]; tuple of np.array shape (3,), or (None, None) if no points. (sec-graphics-boundingbox)= ## Function: BoundingBox [`BoundingBox(graphicsData)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2366) - **function description**: compute bounding box of single GraphicsData or list of GraphicsData - **input**: - `graphicsData`: a single Exudyn GraphicsData object or list - **output**: (type: list) [bmin, bmax]; tuple of np.array shape (3,), or (None, None) if no points. (sec-graphics-frompointsandtrigs)= ## Function: FromPointsAndTrigs [`FromPointsAndTrigs(points, triangles, color = [0.,0.,0.,1.], normals = None)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2397) - **function description**: convert triangles and points as returned from graphics.ToPointsAndTrigs(...) to GraphicsData; additionally, normals and color(s) can be provided - **input**: - `points`: list or np.array with np rows of 3 columns (floats) per point (with np points) - `triangles`: list or np.array with 3 int per triangle (0-based indices to triangles), giving a matrix with nt rows and 3 columns (with nt triangles); a matrix with 6 columns gives 6-node (curved) triangles, corners counter-clockwise and then the mid-side nodes 01, 12, 20 (key 'triangles6') - `color`: provided as list of 4 RGBA values or single list of (np)*[4 RGBA values] - `normals`: if not None, they have to be provided per point (as matrix, list of lists or flattened) and will be added to returned GraphicsData - **output**: returns GraphicsData with type TriangleList Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`NGsolveGeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveGeometry.py) (Ex), [`NGsolveOCCboundaries2.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveOCCboundaries2.py) (Ex), [`NGsolveOCCgeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveOCCgeometry.py) (Ex), [`particlesSilo.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/particlesSilo.py) (Ex), [`pymeshlabFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/pymeshlabFileImport.py) (Ex), [`distanceSensor.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/distanceSensor.py) (TM), [`generalContactFrictionTests.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/generalContactFrictionTests.py) (TM), [`generalContactImplicit1.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/generalContactImplicit1.py) (TM), ... (sec-graphics-topointsandtrigs)= ## Function: ToPointsAndTrigs [`ToPointsAndTrigs(g)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2438) - **function description**: convert graphics data into list of points and list of triangle indices (triplets) - **input**: g contains a GraphicsData with type TriangleList - **output**: returns [points, triangles], with points as list of np.array with 3 floats per point and triangles as a list of np.array with 3 int per triangle (0-based indices to points) Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`mobileMecanumWheelRobotWithLidar.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/mobileMecanumWheelRobotWithLidar.py) (Ex), [`particleClusters.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/particleClusters.py) (Ex), [`particlesSilo.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/particlesSilo.py) (Ex), [`pymeshlabFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/pymeshlabFileImport.py) (Ex), [`reinforcementLearningRobot.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/reinforcementLearningRobot.py) (Ex), [`distanceSensor.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/distanceSensor.py) (TM), [`generalContactCylinderTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/generalContactCylinderTest.py) (TM), [`generalContactCylinderTrigsTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/generalContactCylinderTrigsTest.py) (TM), ... (sec-graphics-transform)= ## Function: Transform [`Transform(graphicsData, translation = None, rotation = None, scale = 1, normalizeNormals = False, invertNormals = False, invertTriangles = False, warn = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2467) - **function description**: transform a GraphicsData object in several ways: move, rotate, scale; furthermore, normals can be fixed and inverted, etc. - **input**: - `g`: graphicsData to be transformed - `translation`: 3D offset as list or numpy.array added to rotated points; if pOff=None, no translation is applied - `rotation`: 3D rotation matrix as list of lists or numpy.array with shape (3,3); if A is scaled by factor, e.g. using 0.001*np.eye(3), you can also scale the coordinates; if Aoff=None, no rotation is performed - `scale`: scaling of position coordinates - `normalizeNormals`: if True, normals are scaled such that length=1 (or zero for zero-normals) - `invertTriangles`: if True, it inverts the triangle orientation (changing vertex index 0 and 1) - `invertNormals`: if True, the direction of normal is flipped - **output**: returns new graphcsData object to be used for drawing in objects - **notes**: the rigid body transformation corresponds to HomogeneousTransformation(rotation, translation), transforming original coordinates v into vNew = translation + rotation @ v (sec-graphics-move)= ## Function: Move [`Move(g, pOff, Aoff = None)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2597) - **function description**: add rigid body transformation and possible scaling to GraphicsData, using position offset (global) pOff (list or np.array) and rotation Aoff (transforms local to global coordinates; list of lists or np.array) - **input**: - `g`: graphicsData to be transformed - `pOff`: 3D offset as list or numpy.array added to rotated points - `Aoff`: 3D rotation matrix as list of lists or numpy.array with shape (3,3); if Aoff=None, no rotation is performed - **output**: returns new graphcsData object to be used for drawing in objects - **notes**: transformation corresponds to HomogeneousTransformation(Aoff, pOff), transforming original coordinates v into vNew = pOff + Aoff @ v Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`ballBearningModel.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ballBearningModel.py) (Ex), [`graphicsCurvedShapes.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsCurvedShapes.py) (Ex), [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex), [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`kinematicTreeAndMBS.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreeAndMBS.py) (Ex), [`raytracerNOGLFWtest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/raytracerNOGLFWtest.py) (TM), [`rigidBodyAsUserFunctionTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/rigidBodyAsUserFunctionTest.py) (TM), ... (sec-graphics-mergetrianglelists)= ## Function: MergeTriangleLists [`MergeTriangleLists(g1, g2)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2615) - **function description**: merge 2 different graphics data with triangle lists - **input**: graphicsData dictionaries g1 and g2 obtained from GraphicsData functions - **output**: one graphicsData dictionary with single triangle lists and compatible points and normals, to be used in visualization of EXUDYN objects; edges are merged; edgeColor is taken from graphicsData g1 Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex), [`mobileMecanumWheelRobotWithLidar.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/mobileMecanumWheelRobotWithLidar.py) (Ex), [`particleClusters.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/particleClusters.py) (Ex), [`particlesSilo.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/particlesSilo.py) (Ex), [`serialRobotKinematicTreeDigging.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotKinematicTreeDigging.py) (Ex), [`distanceSensor.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/distanceSensor.py) (TM), [`generalContactFrictionTests.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/generalContactFrictionTests.py) (TM), [`laserScannerTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/laserScannerTest.py) (TM), ... (sec-graphics-inverttriangles)= ## Function: InvertTriangles [`InvertTriangles(graphicsData, invertTriangles = True, invertNormals = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2672) - **function description**: invert triangle orientation and triangle normals (or only one of these tasks); can also check consistency of normals - **input**: - `graphicsData`: graphicsData as returned e.g. from graphics.Sphere - `invertTriangles`: if True, it inverts the triangle orientation (changing vertex index 0 and 1) - `invertNormals`: if True, the direction of normal is flipped - **output**: returns new graphicsData (copy) with modified triangles and normals (sec-graphics-inconsistenttriangles)= ## Function: InconsistentTriangles [`InconsistentTriangles(graphicsData)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2727) - **function description**: check consistency of orientation of triangles and vertex (point) normals - **input**: - `graphicsData`: graphicsData as returned e.g. from graphics.Sphere - **output**: returns number of cases in which triangle normals and vertex normals are inconsistent (scalar product is negative) Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`graphicsDataExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/graphicsDataExample.py) (Ex) (sec-graphics-ngsolvemesh2pointsandtrigs)= ## Function: NGsolveMesh2PointsAndTrigs [`NGsolveMesh2PointsAndTrigs(mesh = None, ngMesh = None, meshOrder = 2, scale = 1, addNormals = True, verbose = False, triangles6 = False)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2758) - **function description**: convert NGsolve (surface) mesh into (surface) points and triangles; clearly, it requires to have ngsolve installed - **input**: - `mesh`: a ngsolve mesh; having a geometry geo = OCCGeometry(...), mesh is returned from ngsolve.Mesh(geo.GenerateMesh(...)) - `ngMesh`: a netgen mesh; having a geometry geo = OCCGeometry(...), ngMesh is returned from geo.GenerateMesh(...) - `meshOrder`: either 1 (linear, flat triangles) or 2 (quadratic, smooth triangles) - `scale`: additional scaling factor for geometry, as it is recommended to define netgen geometries in mm due to tolerances - `addNormals`: if True, it computes and adds normals - `verbose`: print debug information - `triangles6`: with meshOrder=2, return the elements as 6-node triangles (6 indices per row, for FromPointsAndTrigs), drawn curved, instead of 4 flat triangles each - **output**: [points, triangles] or if addNormals=True, [points, triangles, normals] for further usage in graphics.FromPointsAndTrigs(...) *example*: ```python #assume having already a body of netgen OCCGeometry geo = OCCGeometry(body) ngMesh = geo.GenerateMesh(maxh=maxh) #convert mesh into points, triangles and normals (with second-order elements!) [points, triangles, normals] = graphics.NGsolveMesh2PointsAndTrigs(mesh=ngMesh) #convert into graphicsData gMesh = graphics.FromPointsAndTrigs( points, triangles, normals=normals, color=graphics.color.red) #use the mesh on a ground object mbs.CreateGround(graphicsDataList=[gMesh]) ``` Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`NGsolveOCCboundaries2.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveOCCboundaries2.py) (Ex), [`NGsolveOCCgeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveOCCgeometry.py) (Ex), [`NGsolvePistonEngine.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolvePistonEngine.py) (Ex) (sec-graphics-fromstlfileascii)= ## Function: FromSTLfileASCII [`FromSTLfileASCII(fileName, color = [0.,0.,0.,1.], verbose = False, invertNormals = True, invertTriangles = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2898) - **function description**: generate graphics data from STL file (text format!) and use color for visualization; this function is slow, use stl binary files with FromSTLfile(...) - **input**: - `fileName`: string containing directory and filename of STL-file (in text / SCII format) to load - `color`: provided as list of 4 RGBA values - `verbose`: if True, useful information is provided during reading - `invertNormals`: if True, orientation of normals (usually pointing inwards in STL mesh) are inverted for compatibility in Exudyn - `invertTriangles`: if True, triangle orientation (based on local indices) is inverted for compatibility in Exudyn - **output**: creates graphicsData, inverting the STL graphics regarding normals and triangle orientations (interchanged 2nd and 3rd component of triangle index) Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`NGsolveOCCgeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveOCCgeometry.py) (Ex), [`stlFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/stlFileImport.py) (Ex) (sec-graphics-frompymeshlabfile)= ## Function: FromPyMeshlabFile [`FromPyMeshlabFile(fileName, defaultColor = color.defaultBody, invertNormals = False, invertTriangles = False, normalizeNormals = True, useDefaultColor = False, verbose = False)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L2997) - **function description**: generate graphics data from any file that can be loaded with PyMeshLab (in particular .obj, .dae and .stl); either use defaultColor or given color in mesh. - **input**: - `fileName`: string containing directory and filename of geometry file - `defaultColor`: provided as list of 4 RGBA values; used only if meshlab cannot load valid color or if file does not include color (e.g., STL) - `verbose`: if True, some information is logged during file import - `invertNormals`: if True, orientation of normals (usually pointing inwards in STL mesh) are inverted for compatibility in Exudyn - `invertTriangles`: if True: triangle orientation (based on local indices) is inverted for compatibility in Exudyn - `normalizeNormals`: if True, normals are scaled such that length=1 (or zero for zero-normals) - `useDefaultColor`: if True: ignores colors of the loaded mesh and uses defaultColor - **output**: (type: dict) graphicsData in Exudyn dictionary format - **notes**: requires pymeshlab to be installed (pip install pymeshlab); materials and textures are currently not considered in the import functionality! Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`pymeshlabFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/pymeshlabFileImport.py) (Ex) (sec-graphics-fromstlfile)= ## Function: FromSTLfile [`FromSTLfile(fileName, color = [0.,0.,0.,1.], verbose = False, density = 0., scale = 1., Aoff = [], pOff = [], invertNormals = True, invertTriangles = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L3078) - **function description**: generate graphics data from STL file, allowing text or binary format; requires numpy-stl to be installed; additionally can scale, rotate and translate - **input**: - `fileName`: string containing directory and filename of STL-file (in text / SCII format) to load - `color`: provided as list of 4 RGBA values - `verbose`: if True, useful information is provided during reading - `density`: if given and if verbose, mass, volume, inertia, etc. are computed - `scale`: point coordinates are transformed by scaling factor - `invertNormals`: if True, orientation of normals (usually pointing inwards in STL mesh) are inverted for compatibility in Exudyn - `invertTriangles`: if True, triangle orientation (based on local indices) is inverted for compatibility in Exudyn - **output**: creates graphicsData, inverting the STL graphics regarding normals and triangle orientations (interchanged 2nd and 3rd component of triangle index) - **notes**: the model is first scaled, then rotated, then the offset pOff is added; finally min, max, mass, volume, inertia, com are computed! Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`ROSTurtle.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ROSTurtle.py) (Ex), [`stlFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/stlFileImport.py) (Ex) (sec-graphics-addedgesandsmoothennormals)= ## Function: AddEdgesAndSmoothenNormals [`AddEdgesAndSmoothenNormals(graphicsData, edgeColor = color.black, edgeAngle = 0.25*pi, addEdges = True, smoothNormals = True, roundDigits = 5, triangleColor = [])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L3156) - **function description**: compute and return GraphicsData with edges and smoothend normals for mesh consisting of points and triangles (e.g., as returned from GraphicsData2PointsAndTrigs); ignores stored normals graphicsData: single GraphicsData object of type TriangleList; existing edges are ignored edgeColor: optional color for edges edgeAngle: angle above which edges are added to geometry addEdges: if True, edges are added in TriangleList of GraphicsData smoothNormals: if True, algorithm tries to smoothen normals at vertices; otherwise, uses triangle normals roundDigits: number of digits, relative to max dimensions of object, at which points are assumed to be equal; too small or too larger number of digits may cause artifacts triangleColor: if triangleColor is set to a RGBA color, this color is used for the new triangle mesh throughout; otherwise, stored colors are unchanged - **output**: returns GraphicsData with added edges and smoothed normals - **notes**: this function is suitable for STL import; it assumes that all colors in graphicsData are the same and only takes the first color! Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`NGsolveGeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveGeometry.py) (Ex), [`NGsolveOCCgeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveOCCgeometry.py) (Ex), [`pymeshlabFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/pymeshlabFileImport.py) (Ex), [`stlFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/stlFileImport.py) (Ex) (sec-graphics-exportstl)= ## Function: ExportSTL [`ExportSTL(graphicsData, fileName, solidName = 'ExudynSolid', invertNormals = True, invertTriangles = True)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/graphics.py#L3327) - **function description**: export given graphics data (only type TriangleList allowed!) to STL ascii file using fileName - **input**: - `graphicsData`: a single GraphicsData dictionary with type='TriangleList', no list of GraphicsData - `fileName`: file name including (local) path to export STL file - `solidName`: optional name used in STL file - `invertNormals`: if True, orientation of normals (usually pointing inwards in STL mesh) are inverted for compatibility in Exudyn - `invertTriangles`: if True, triangle orientation (based on local indices) is inverted for compatibility in Exudyn Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`NGsolveOCCgeometry.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/NGsolveOCCgeometry.py) (Ex), [`stlFileImport.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/stlFileImport.py) (Ex) (sec-module-graphics-class-color)= ## CLASS color (in module graphics) **class description**: A structure with default values representing RGBA-colors (list of 4 values ranging from 0 to 1); users will access colors via graphics.color, e.g., graphics.color.red Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`contactSphereSphereTestEAPM.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/contactSphereSphereTestEAPM.py) (TM) (sec-module-graphics-class-material)= ## CLASS material (in module graphics) **class description**: A structure that defines material indices and RGBA-values for standard materials; the material index (like indexChrome) can be used for the alpha-channel of a color to represent the material index; used only in the raytracer!