To rotate around an arbitrary point, center, you do
translate(center)rotate(.....)translate(-center). The BOSL2 library
has a rot() function that accepts a centerpoint argument, so you can
do it there with rot(...., cp=center).
On Sat, Mar 12, 2022 at 7:29 AM Jan Öhman via Discuss
discuss@lists.openscad.org wrote:
---------- Forwarded message ----------
From: "Jan Öhman" jan_ohman@yahoo.com
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc:
Bcc:
Date: Sat, 12 Mar 2022 12:30:01 +0000 (UTC)
Subject: [OpenSCAD] Rotate some objects around a selected point
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.
but
My 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;
// wheel
wheelDiam = 20;
wheelWidth = 8;
x2=x1+length2;
y2=y1;
z2=z1;
// Create the Axle1
translate([x1, y1, z1])
rotate([0,-90,0]) cylinder(h=length1, d=width1);
// Create the Axle2
translate([x1, y1, z1])
rotate([0,90,0]) cylinder(h=length2, d=width2);
// Mount the "knot"
translate([x1, y1, z1]) sphere(d=knot);
// Mount the Wheel
translate([x2, y2, z2])
rotate([0,90,0]) cylinder(d=wheelDiam, h=wheelWidth);
---------- Forwarded message ----------
From: "Jan Öhman via Discuss" discuss@lists.openscad.org
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc: "Jan Öhman" jan_ohman@yahoo.com
Bcc:
Date: Sat, 12 Mar 2022 12:30:01 +0000 (UTC)
Subject: [OpenSCAD] Rotate some objects around a selected point
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I have made few changes in your code to achieve what you are looking for
(if i understand correctly)
$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;
// wheel
wheelDiam = 20;
wheelWidth = 8;
x2=x1+length2;
y2=y1;
z2=z1;
// Create the Axle1
translate([x1, y1, z1])
rotate([0,-90,0]) cylinder(h=length1, d=width1);
translate([x1, y1, z1])
rotate([0,0,-20])
union(){
// Create the Axle2
rotate([0,90,0]) cylinder(h=length2, d=width2);
// Mount the "knot"
sphere(d=knot);
// Mount the Wheel
translate([length2, 0, 0])
rotate([0,90,0]) cylinder(d=wheelDiam, h=wheelWidth);}
On Sat, 12 Mar 2022 at 19:13, Adrian Mariano avm4@cornell.edu wrote:
To rotate around an arbitrary point, center, you do
translate(center)rotate(.....)translate(-center). The BOSL2 library
has a rot() function that accepts a centerpoint argument, so you can
do it there with rot(...., cp=center).
On Sat, Mar 12, 2022 at 7:29 AM Jan Öhman via Discuss
discuss@lists.openscad.org wrote:
---------- Forwarded message ----------
From: "Jan Öhman" jan_ohman@yahoo.com
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc:
Bcc:
Date: Sat, 12 Mar 2022 12:30:01 +0000 (UTC)
Subject: [OpenSCAD] Rotate some objects around a selected point
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.
but
My 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;
// wheel
wheelDiam = 20;
wheelWidth = 8;
x2=x1+length2;
y2=y1;
z2=z1;
// Create the Axle1
translate([x1, y1, z1])
rotate([0,-90,0]) cylinder(h=length1, d=width1);
// Create the Axle2
translate([x1, y1, z1])
rotate([0,90,0]) cylinder(h=length2, d=width2);
// Mount the "knot"
translate([x1, y1, z1]) sphere(d=knot);
// Mount the Wheel
translate([x2, y2, z2])
rotate([0,90,0]) cylinder(d=wheelDiam, h=wheelWidth);
---------- Forwarded message ----------
From: "Jan Öhman via Discuss" discuss@lists.openscad.org
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc: "Jan Öhman" jan_ohman@yahoo.com
Bcc:
Date: Sat, 12 Mar 2022 12:30:01 +0000 (UTC)
Subject: [OpenSCAD] Rotate some objects around a selected point
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org