Initial coords for Cube
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
// Short for "coordinate system", including translation, rotation, and scale
|
// Short for "coordinate system", including translation, rotation, and scale
|
||||||
// coord:
|
// coord:
|
||||||
// fKeyType "type" fType(): fTypeCoord "coord"
|
// fKeyType "type" fType(): fTypeCoord "coord"
|
||||||
// fKeyTranslation "translation" fCoordTranslation():
|
// fKeyTranslation "translation" fCoordTranslation(): [ x, y, z ]
|
||||||
|
// fKeyRotation "rotation" fCoordRotation(): [ x, y, z ]
|
||||||
|
// fKeyScale "scale" fCoordScale(): [ x, y, z ]
|
||||||
|
|
||||||
fTypeCoord = "coord";
|
fTypeCoord = "coord";
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ function fCube(dims) = (
|
|||||||
[4, 5, 7, 6], // +x
|
[4, 5, 7, 6], // +x
|
||||||
[2, 6, 7, 3], // +y
|
[2, 6, 7, 3], // +y
|
||||||
[1, 3, 7, 5], // +z
|
[1, 3, 7, 5], // +z
|
||||||
|
],
|
||||||
|
coords=[
|
||||||
|
[ "/x+,/y+,-z+", fCoord(translation=[x / 2, y / 2, 0]) ],
|
||||||
|
[ "/x+,/y+,+z+", fCoord(translation=[x / 2, y / 2, z]) ],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
/// fKeyType "type" fType(): fTypeModel "model"
|
/// fKeyType "type" fType(): fTypeModel "model"
|
||||||
/// fKeyPoints "points" fModelPoints(): [ [x, y, z], ... ]
|
/// fKeyPoints "points" fModelPoints(): [ [x, y, z], ... ]
|
||||||
/// fKeyFaces "faces" fModelFaces(): [ [ pointIdx, ... ], ... ]
|
/// fKeyFaces "faces" fModelFaces(): [ [ pointIdx, ... ], ... ]
|
||||||
|
/// fKeyCoords "coords" fModelCoords(): [ [ name, coord ], ... ]
|
||||||
|
|
||||||
|
/// Standard model coords names:
|
||||||
|
///
|
||||||
|
/// [-/+] edge ("/" is midpoint)
|
||||||
|
/// [xyz] axis
|
||||||
|
/// [-+] direction
|
||||||
|
/// [-/+]x[-+],[-/+]y[-+],[-/+]z[-+]
|
||||||
|
|
||||||
fTypeModel = "model";
|
fTypeModel = "model";
|
||||||
|
|
||||||
@@ -11,12 +19,14 @@ function fIsModel(x) = (
|
|||||||
|
|
||||||
fKeyPoints = "points";
|
fKeyPoints = "points";
|
||||||
fKeyFaces = "faces";
|
fKeyFaces = "faces";
|
||||||
|
fKeyCoords = "coords";
|
||||||
|
|
||||||
function fModel(points, faces) = (
|
function fModel(points, faces, coords=[]) = (
|
||||||
[
|
[
|
||||||
[fKeyType, fTypeModel],
|
[fKeyType, fTypeModel],
|
||||||
[fKeyPoints, points],
|
[fKeyPoints, points],
|
||||||
[fKeyFaces, faces],
|
[fKeyFaces, faces],
|
||||||
|
[fKeyCoords, coords],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -27,3 +37,19 @@ function fModelPoints(model) = (
|
|||||||
function fModelFaces(model) = (
|
function fModelFaces(model) = (
|
||||||
fMapLookup(fKeyFaces, model)
|
fMapLookup(fKeyFaces, model)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fCoordAliases = [
|
||||||
|
[ "bottom", "/x+,/y+,-z+" ],
|
||||||
|
[ "top", "/x+,/y+,+z+" ],
|
||||||
|
[ "center", "/x+,/y+,/z+" ],
|
||||||
|
];
|
||||||
|
|
||||||
|
function fModelCoords(model) = (
|
||||||
|
fMapLookup(fKeyCoords, model)
|
||||||
|
);
|
||||||
|
|
||||||
|
function fModelCoord(model, name) = (
|
||||||
|
let(alias = fMapLookup(name, fCoordAliases),
|
||||||
|
realName = alias ? alias : name)
|
||||||
|
fMapLookup(realName, fModelCoords(model))
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user