discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Rotate some objects around a selected point

Jan Öhman
Sat, Mar 12, 2022 12:30 PM

Assume the following (a slightly simplified example)

There are two axles (one long and one short) with a knot (sphere) between them.
On the short one, a wheel is placed.
This code below puts these parts together.

butMy wish is to turn the wheel and the short axle (and maybe the knot) for example 20 degrees (right / left), around the knot.
(not at the center of the wheel and short axle)
$fn=100;
// axle1 (the long one)length1 = 10;width1 = 3;x1=10;y1=10;z1= 0;
// axle2 (the short one)length2 = 3;width2 = 3;
// The "knot"knot = width1 + 2;
// wheelwheelDiam = 20;wheelWidth = 8;x2=x1+length2;y2=y1;z2=z1;
// Create the Axle1translate([x1, y1, z1])    rotate([0,-90,0]) cylinder(h=length1, d=width1);
// Create the Axle2translate([x1, y1, z1])    rotate([0,90,0]) cylinder(h=length2, d=width2);
// Mount the "knot"translate([x1, y1, z1]) sphere(d=knot);
// Mount the Wheeltranslate([x2, y2, z2])    rotate([0,90,0]) cylinder(d=wheelDiam, h=wheelWidth);

Assume the following (a slightly simplified example) There are two axles (one long and one short) with a knot (sphere) between them. On the short one, a wheel is placed. This code below puts these parts together. butMy wish is to turn the wheel and the short axle (and maybe the knot) for example 20 degrees (right / left), around the knot. (not at the center of the wheel and short axle) $fn=100; // axle1 (the long one)length1 = 10;width1 = 3;x1=10;y1=10;z1= 0; // axle2 (the short one)length2 = 3;width2 = 3; // The "knot"knot = width1 + 2; // wheelwheelDiam = 20;wheelWidth = 8;x2=x1+length2;y2=y1;z2=z1; // Create the Axle1translate([x1, y1, z1])    rotate([0,-90,0]) cylinder(h=length1, d=width1); // Create the Axle2translate([x1, y1, z1])    rotate([0,90,0]) cylinder(h=length2, d=width2); // Mount the "knot"translate([x1, y1, z1]) sphere(d=knot); // Mount the Wheeltranslate([x2, y2, z2])    rotate([0,90,0]) cylinder(d=wheelDiam, h=wheelWidth);