Primitives Reference: Difference between revisions

From LDraw.org Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 219: Line 219:
| [[File:box3-12.png|200px|thumb|alt=Box3-12]]
| [[File:box3-12.png|200px|thumb|alt=Box3-12]]
|| This primitive represents a cuboid missing the top {-y}, front {-z} and left {-x} faces but excludes all edges. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
|| This primitive represents a cuboid missing the top {-y}, front {-z} and left {-x} faces but excludes all edges. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
|
|-


| '''box3u2p.dat''' || '''Cuboid with 3 faces missing 2 edges'''
| '''box3u2p.dat''' || '''Cuboid with 3 faces missing 2 edges'''
Line 237: Line 237:
| [[File:box3u4a.png|200px|thumb|alt=Box3u4a]]
| [[File:box3u4a.png|200px|thumb|alt=Box3u4a]]
|| This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the edges of the missing top face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
|| This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the edges of the missing top face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
|
|-


| '''box3u5p.dat''' || '''Cuboid with 3 faces missing 5 edges'''
| '''box3u5p.dat''' || '''Cuboid with 3 faces missing 5 edges'''
Line 352: Line 352:
To avoid rounding errors, it is preferable to use existing fractional circular primitives, or create a new primitive, rather than rotate an existing primitive by anything other than 90 or 180 degrees. For example, use 3-16XXXX.dat rather than combining 1-8XXXX.dat with 1-16XXXX.dat rotated by 22.5 degreees.
To avoid rounding errors, it is preferable to use existing fractional circular primitives, or create a new primitive, rather than rotate an existing primitive by anything other than 90 or 180 degrees. For example, use 3-16XXXX.dat rather than combining 1-8XXXX.dat with 1-16XXXX.dat rotated by 22.5 degreees.


<gallery widths=200px>
<gallery widths=200px mode="nolines">
XZaxes.png
XZaxes.png
1-8disc.png
1-8disc.png

Revision as of 18:52, 29 November 2023

LDraw Primitives Reference

This page is a source of reference for the LDraw primitives in the \LDraw\p directory. Primitives are defined as highly re-usable components of LEGO parts modelled for LDraw. They serve several purposes :

   * To speed up parts authoring by providing a library of components which can be incorporated into several parts
   * To allow rendering software to make substitutions of curved components

Within this reference material the available primitives are categorised into:


Each section contains an overview of the characteristics common to all primitives within that category. Primitives are grouped into classes within each category - one class of primitive serving a similar purpose at different sizes or resolutions. For each class of primitive, a brief description of the purpose of the primitive is provided, with notes on its co-ordinate origin, default size and rules for scaling. A list of the available primitives is shown.

An understanding of the orientation of the co-ordinate axes is essential for authoring a part for LDraw. For reference within this page the axes and their direction is shown in this diagram.

Axes

Rectilinear primitives

These rectilinear elements may be scaled in the {x}, {y} and {z} dimensions to make elements of any size. For example

1 16    0 0 0    40 0 0    0 1 0    0 0 20    rect.dat

would generate a 80LDu x 40LDu rectangle in the {x,z} plane.

Although the default orientation of the rect.dat primitive is in the {x,z} plane the LDraw language allows for this to be transformed

1 16    0 0 0    0 1 0    40 0 0    0 0 20    rect.dat

would generate a 80LDu x 40LDu rectangle in the {y,z} plane.

1 16    0 0 0    40 0 0    0 0 20    0 1 0    rect.dat

would generate a 80LDu x 40LDu rectangle in the {x,y} plane.

Two dimensional

rect.dat Rectangle with all edges
Rect
This primitive represents a rectangle in the {x,z} plane and the four edges that bound it. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions. To avoid matrix arithmetic problems in some renderers, the third dimension ({y} in the default orientation) must be given a non-zero scaling factor.

1 16    0 0 0    5 0 0    0 1 0    0 0 20    rect.dat

rect3.dat Rectangle with 3 edges
Rect3
This primitive represents a rectangle in the {x,z} plane but excludes one edge {-z}. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
rect2p.dat Rectangle with 2 parallel edges
Rect2p
This primitive represents a rectangle in the {x,z} plane but excludes two parallel edges ({+x} and {-x}). Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
rect2a.dat Rectangle with 2 adjacent edges
Rect2a
This primitive represents a rectangle in the {x,z} plane but excludes two adjacent edges ({-x} and {-z}). Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
rect1.dat Rectangle with 1 edge
Rect1
This primitive represents a rectangle in the {x,z} plane but include only the one {+x} edge. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
recte3.dat Empty rectangle with three edges
Recte3
This primitive represents three edges of a rectangle in the {x,z} plane. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.
recte4.dat Empty rectangle with all edges
Recte4
This primitive represents the four edges of a rectangle in the {x,z} plane. Its origin is at its centre and by default has a size of 2LDu in each of the {x} and {z} dimensions.


Three dimensional

box.dat Cuboid with all faces and edges
Box
This primitive is used to define a cuboid. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the three dimensions.
box0.dat Cuboid with no faces and edges
Box0
This primitive is used to define the frame a cuboid. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the three dimensions.
box5.dat Cuboid with 5 faces and all edges
Box5
This primitive represents a cuboid missing the top {-y} face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-1.dat Cuboid with 5 faces without 1 edge
Box5-1
This primitive represents a cuboid missing the top {-y} face and one edge {-z} of that. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-2p.dat Cuboid with 5 faces without 2 parallel edges
Box5-2p
This primitive represents a cuboid missing the top {-y} face and two of the four edges surrounding that. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-4a.dat Cuboid with 5 faces without top edges
Box5-4a
This primitive represents a cuboid missing the top {-y} face and the four edges surrounding that. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box5-12.dat Cuboid with 5 faces missing all edges
Box5-12
This primitive represents a cuboid missing the top {-y} face and all edges. Its primary use is for sticker parts. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4.dat Cuboid with 4 parallel faces and all edges
Box4
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4o4a.dat Cuboid with 4 parallel faces without bottom edges
Box4o4a
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing the edges of the bottom face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4o8a.dat Cuboid with 4 parallel faces without top and bottom edges
Box4o8a
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing the edges of the top and bottom face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4t.dat Cuboid with 4 adjacent and all edges
Box4t
This primitive represents a cuboid missing the top {-y} and front {-z} faces, but with all its edges. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-1.dat Cuboid with 4 adjacent faces missing 1 edge
Box4-1
This primitive represents a cuboid missing the top {-y} and front {-z} faces and the edge between those faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-2p.dat Cuboid with 4 faces without two opposite top edges
Box4-2p
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing two edges of the top face - the intersection of the two missing faces and the opposite edge. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-3p.dat Cuboid with 4 faces without three parallel edges
Box4-3p
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing three edges of the missing faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-4a.dat Cuboid with 4 adjacent faces missing 4 edges
Box4-4a
This primitive represents a cuboid missing the top {-y} and front {-z} faces and all the edges of the missing front face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box4-7a.dat Cuboid with 4 adjacent faces missing 7 edges
Box4-7a
This primitive represents a cuboid missing the top {-y} and front {-z} faces and all the edges of both missing faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3-3.dat Cuboid with 3 adjacent faces missing 3 edges
Box3-3
This primitive represents a cuboid missing the top {-y} and bottom {+y} faces, and missing three edges of the missing faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3-5a.dat Cuboid with 4 adjacent faces missing 4 edges
Box3-5a
This primitive represents a cuboid missing the top {-y}, front {-z} and left {-x} faces and includes the three internal edges and the outer edges except those on the left {-z}. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box3-7a.dat Cuboid with 3 adjacent faces missing 7 adjacent edges
Box3-7a
This primitive represents a cuboid missing the top {-y}, front {-z} and left {-x} faces and includes the three internal edges but only the outer edges at the top (-y). Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box3-9a.dat Cuboid with 3 adjacent faces missing 9 adjacent edges
Box3-9a
This primitive represents a cuboid missing the top {-y}, front {-z} and left {-x} faces and includes only the three internal edges. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box3-12.dat Cuboid with 3 adjacent faces missing all edges
Box3-12
This primitive represents a cuboid missing the top {-y}, front {-z} and left {-x} faces but excludes all edges. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box3u2p.dat Cuboid with 3 faces missing 2 edges
Box3u2p
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the top edges of the left {-x} and right {+x} faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u4p.dat Cuboid with 3 faces missing 4 parallel edges
Box3u4p
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the topand bottom edges of the left {-x} and right {+x} faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u4a.dat Cuboid with 3 adjacent faces missing all edges
Box3u4a
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the edges of the missing top face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u5p.dat Cuboid with 3 faces missing 5 edges
Box3u5p
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the top edge of the left {-x} face and all edges of the right {+x} face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u6.dat Cuboid with 3 faces missing 6 edges
Box3u6
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the top and bottome edges of the right {+x} face and all edges of the left {-x} face. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u7a.dat Cuboid with 3 faces missing 7 adjacent edges
Box3u7a
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes the edges of the missing top (-y) and right (+x) faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u8p.dat Cuboid with 3 faces missing 8 edges (in two parallel groups)
Box3u8p
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes all the edges of the left {-x} and right {+x} faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u10p.dat Cuboid with 3 faces in a 'U' shape, missing 10 edges (all except those between the faces)
Box3u10p
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes all the edges except the two betweenthe faces. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
box3u12.dat Cuboid with 3 parallel faces missing all edges
Box3u12
This primitive represents a cuboid missing the top {-y} and left {-x} and right {+x} faces and excludes all the edges. Its origin is the centre of the (missing) top face and by default has a size of 2LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
boxjcyl4.dat Box truncated by cylinder
Boxjcyl4
This suite of primitives are used to model the intersection between a box and cylinders of different radii. The box has a fixed width of 2LDu and the cylinder radius is denoted by the r in the filename.

Currently available primitives : Regular resolution (boxjcylr) : 4

box2-5.dat Cuboid with 2 adjacent faces missing 5 edges
Box2-5
This primitive represents a cuboid missing the top {-y}, front {-z}, left {-x} and right {+x} faces and excludes all the edges which do not bound the included faces. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box2-7.dat Cuboid with 2 adjacent faces missing 7 edges
Box2-7
This primitive represents a cuboid missing the top {-y}, front {-z}, left {-x} and right {+x} faces and excludes all the edges except that at the join between the two faces and those along the left {-x} and right {+x} sides. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box2-9.dat Cuboid with 2 adjacent faces missing 9 edges (all except those connected to the {+x}, {+y}, {+z} vertex)
Box2-9
This primitive represents a cuboid missing the top {-y}, front {-z}, left {-x} and right {+x} faces and excludes all the edges except that at the join between the two faces and those along the right {+x} sides. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box2-9p.dat Cuboid with 2 adjacent faces missing 9 edges (all except three parallel edges)
Box2-9p
This primitive represents a cuboid missing the top {-y}, front {-z}, left {-x} and right {+x} faces and excludes all the edges except that at the join between the two faces and those parallel to that. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
box2-11.dat Cuboid with 2 adjacent faces missing 11 edges
Box2-11
This primitive represents a cuboid missing the top {-y}, front {-z}, left {-x} and right {+x} faces and excludes all the edges except that at the join between the two faces. Its origin is the centre of the cuboid and by default has a size of 2LDu in each of the {x}, {y} and {z} dimensions.
tri3.dat Right-angled triangular prism with 3 faces
Tri3
This primitive represents a triangular prism missing the top {-y} and bottom {+y} faces but including all edges. The left {-x} and front {-z} faces are perpendicular. Its origin is the right-angle corner of the (missing) top face and by default has a size of 1LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
tri3a1.dat Right-angled triangular prism with 3 adjacent faces missing 1 edge
Tri3a1
tri3a4 Right-angled triangular prism with 3 adjacent faces missing 4 adjacent edges
Tri3a4
tri3u1.dat Right-angled triangular prism with 3 faces missing 1 edge
Tri3u1
This primitive represents a triangular prism missing the left {-x} and front {-z} faces. Its origin is the right-angle corner of the top face and by default has a size of 1LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.
tri3u3.dat Right-angled triangular prism with 3 faces missing 3 edges
Tri3u3
This primitive represents a triangular prism missing the left {-x} and front {-z} faces, the edge where they would join and one edge of each of the triangles. Its origin is the right-angle corner of the top face and by default has a size of 1LDu in each of the {x} and {z} dimensions and 1LDu in the {y} dimension.

Curved primitives

LDraw represents curved surfaces as polygons. For circular components two series of primitives are provided.

All the circular primitives are orientated in the {x,z} plane with their origin at the centre of the circle and a default radius of 1 LDu. Primitives are provided for complete circles and for commonly used fractions of a complete circle. Where the naming convention includes a prefix of the form n-f this indicates the fraction (n/f) of the circle drawn by the primitive. Where this fraction is less than an entire circle, the primitive starts at {+x,0} and progresses in a conterclockwise direction when viewed from above {-y}.

To avoid rounding errors, it is preferable to use existing fractional circular primitives, or create a new primitive, rather than rotate an existing primitive by anything other than 90 or 180 degrees. For example, use 3-16XXXX.dat rather than combining 1-8XXXX.dat with 1-16XXXX.dat rotated by 22.5 degreees.

To avoid matrix arithmetic problems in some renderers, the third dimension ({y} in the default orientation) of two-dimensional primitives must be given a non-zero scaling factor. LDraw circles are normally formed of 16-sided polygons (hexdecagons) - the regular resolution. For larger elements, where scaling-up of hexadecagons would give too angular an appearance, a series of high resolution primitives based on a 48-sided polygon are available. These may also be used for parts not well suited to a 16-fold symmetry.

These circular elements may be scaled by the same factor in both the {x} and {z} dimensions to make circular elements of greater or less than 1LDu radius. For example

1 16    0 0 0    3 0 0    0 1 0    0 0 3    4-4edge.dat

would generate a circle in the {x,z} plane with a radius of 3LDu.

They may also be scaled asymmetrically in the x and z dimension to make ellipses.

Although the default orientation is in the {x,z} plane the LDraw language allows for these to be transformed

1 16    0 0 0    0 1 0    3 0 0    0 0 3    4-4edge.dat    would generate a circle in the {y,z} plane

1 16    0 0 0    3 0 0    0 0 3    0 1 0    4-4edge.dat    would generate a circle in the {x,y} plane

Two dimensional

n-fedge.dat Circular line segment
4-4Edge
This suite of primitives are used for edges which comprise an entire or part circle.

Currently available primitives:
Regular resolution (n-f) : 1-16, 1-8, 3-16, 1-4, 5-16, 3-8, 7-16, 2-4, 9-16, 5-8, 11-16, 3-4, 7-8, 4-4
High resolution (n-f) : 1-48, 1-24, 1-16, 1-12, 5-48, 1-8, 7-48, 1-6, 3-16, 5-24, 1-4, 7-24, 5-16, 1-3, 3-8, 19-48, 5-12, 7-16, 11-24, 2-4, 5-8, 2-3, 3-4, 4-4