mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-08-08 08:26:29 +02:00
added a function to rotate around the dim axis
This commit is contained in:
@@ -30,7 +30,7 @@ module dimensions_3d_xy() {
|
|||||||
dimension([0,0,0], [0,10,0], "", 0.2);
|
dimension([0,0,0], [0,10,0], "", 0.2);
|
||||||
dimension([0,0,0], [0,-10,0], "", 0.2);
|
dimension([0,0,0], [0,-10,0], "", 0.2);
|
||||||
dimension([0,0,0], [10,0,0], "", 0.2);
|
dimension([0,0,0], [10,0,0], "", 0.2);
|
||||||
dimension([0,0,0], [-10,0,0], "", 0.2);
|
dimension([0,0,0], [-10,0,0], "", 0.2, rot_around_dim=270);
|
||||||
}
|
}
|
||||||
|
|
||||||
module dimensions_3d_xyz() {
|
module dimensions_3d_xyz() {
|
||||||
|
@@ -27,7 +27,7 @@ include <../utils/maths.scad>
|
|||||||
|
|
||||||
|
|
||||||
//if text is empty, will display the number value
|
//if text is empty, will display the number value
|
||||||
module dimension(startpoint, endpoint, text = "", thickness = 0.1) {
|
module dimension(startpoint, endpoint, text = "", thickness = 0.1, rot_around_dim = 0) {
|
||||||
// Compute vector between points
|
// Compute vector between points
|
||||||
direction = endpoint - startpoint;
|
direction = endpoint - startpoint;
|
||||||
length = norm(direction);
|
length = norm(direction);
|
||||||
@@ -60,8 +60,10 @@ module dimension(startpoint, endpoint, text = "", thickness = 0.1) {
|
|||||||
// Draw the text/distance
|
// Draw the text/distance
|
||||||
dir = (length > 0) ? (direction / length) * thickness * 4 : [1, 0, 0];
|
dir = (length > 0) ? (direction / length) * thickness * 4 : [1, 0, 0];
|
||||||
up_dir = transform([0,1,0], rotate(azimuth));
|
up_dir = transform([0,1,0], rotate(azimuth));
|
||||||
|
depth_dir = transform([0,0,1], rotate(azimuth));
|
||||||
|
|
||||||
translate(midpoint + up_dir*thickness)
|
rotate(direction*rot_around_dim/2)
|
||||||
|
translate(midpoint + up_dir*thickness - depth_dir*thickness/2)
|
||||||
rotate([0, elevation, azimuth])
|
rotate([0, elevation, azimuth])
|
||||||
linear_extrude(thickness)
|
linear_extrude(thickness)
|
||||||
text(text == "" ? str(length) : text, size = thickness * 5, valign = "bottom", halign = "center");
|
text(text == "" ? str(length) : text, size = thickness * 5, valign = "bottom", halign = "center");
|
||||||
|
Reference in New Issue
Block a user