Hello all,
I am a newbie in OpenSCAD. A few objects have worked well. Now I come to a
problem that I can not fix.
I have a bar of 100 and I want to bend it 25° after 25.
Therefore I have made the following:
I have one cube with 25 and the other with 75.
cube([10, 25, 10.5], center=true);
color("red")
rotate([0,0,25])
translate([(-10.5)/2+0.45, -46.6, 0])
cube([10, 75, 10.5], center=true);
With the command rotate I do not get on so properly.
How can I get this better so that the two edges also fit?
Thanks
Mike
--
Sent from: http://forum.openscad.org/
You have to to 3 steps
--
Sent from: http://forum.openscad.org/
This animation will show you whats happening (so you can better understand)
--
Sent from: http://forum.openscad.org/
Or even better with these timing parameters
--
Sent from: http://forum.openscad.org/
That works only for the single case of 'bends' parallel to the side of
the 'cube'. In other instances the joint probably has to be mitred, (or
worse - tapered cylinder?)
On 17/04/2021 10:07, bassklampfe wrote:
You have to to 3 steps
cube([10, 25, 10.5], center=true);
color("red")
translate([10/2,25/2, 0])
rotate([0,0,25])
translate([-10/2,75/2, 0])
cube([10, 75, 10.5], center=true);
Sent from the OpenSCAD mailing list archive
http://forum.openscad.org/ at Nabble.com.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Thank you bassklampfe.
Now my understanding about the rotate is better.
And also I will change something in future too:
first create the objetct then I will translate to the target position.
--
Sent from: http://forum.openscad.org/
The simplest way to do this is the way bassklampfe showed, but he is mistaken in thinking that 3 steps are required. It can be done with two steps, as you were trying to do, but your translation vector is incorrect. I’m not sure how you arrived at the numbers you used, but this is the correct way to calculate the translation vector.
/*
object is rotated about z-axis
before transformation, the corner you want to align is located at (-5,+37.5)
and you want it to be at (-5,-12.5)
if you're going to translate it first, then rotate it, you need to translate
it to a position that will wind up at (-5,-12.5) when rotated 25 degrees.
The way to find that position is to rotate (-5, -12.5) by -25 degrees, and
see where it ends up. This is most easily done by transforming (-5, -12.5)
from the rectangular coordinates (x, y) to polar coordinates (r, theta):
r = sqrt(x^2 + y^2) = sqrt((-5)^2 + (-12.5)^2) = sqrt(25 + 156.25) = 13.4629
theta = atan(y/x) = atan(-12.5/-5) = atan(2.5) = 68.1986 degrees
but since the point is in Quadrant III, not Quadrant I, we need to add 180
degrees to get the true angle of 248.1986
now rotate -25 degrees to 223.1986 and re-convert to rectangular coordinates
x = r cos(theta) = 13.4629 * cos(223.1986) = -9.8143
y = r sin(theta) = 13.4629 * sin(223.1986) = -9.2157
corner is at (-5, 37.5) and needs to be at (-9.8143, -9.2157)
so translate (-4.8143, -46.7157)
*/
cube([10, 25, 10.5], center=true);
color("red")
rotate([0,0,25])
//translate([(-10.5)/2+0.45, -46.6, 0])
translate ([-4.8143, -46.7157, 0])
cube([10, 75, 10.5], center=true);
// et voila
I found this https://stackoverflow.com/questions/45826208/openscad-rotating-around-a-particular-point
module rotate_about_pt(z, y, pt) {
translate(pt)
rotate([0, y, z])
translate(-pt)
children();
}
It took me a bit to figure it out, but it does work.
“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” (Bill Waterson: Calvin & Hobbes)
On April 18, 2021 at 12:07 PM, doug@milmac.com wrote:
The simplest way to do this is the way bassklampfe showed, but he is mistaken in thinking that 3 steps are required. It can be done with two steps, as you were trying to do, but your translation vector is incorrect. I’m not sure how you arrived at the numbers you used, but this is the correct way to calculate the translation vector.
/*
object is rotated about z-axis
before transformation, the corner you want to align is located at (-5,+37.5)
and you want it to be at (-5,-12.5)
if you're going to translate it first, then rotate it, you need to translate
it to a position that will wind up at (-5,-12.5) when rotated 25 degrees.
The way to find that position is to rotate (-5, -12.5) by -25 degrees, and
see where it ends up. This is most easily done by transforming (-5, -12.5)
from the rectangular coordinates (x, y) to polar coordinates (r, theta):
r = sqrt(x^2 + y^2) = sqrt((-5)^2 + (-12.5)^2) = sqrt(25 + 156.25) = 13.4629
theta = atan(y/x) = atan(-12.5/-5) = atan(2.5) = 68.1986 degrees
but since the point is in Quadrant III, not Quadrant I, we need to add 180
degrees to get the true angle of 248.1986
now rotate -25 degrees to 223.1986 and re-convert to rectangular coordinates
x = r cos(theta) = 13.4629 * cos(223.1986) = -9.8143
y = r sin(theta) = 13.4629 * sin(223.1986) = -9.2157
corner is at (-5, 37.5) and needs to be at (-9.8143, -9.2157)
so translate (-4.8143, -46.7157)
*/
cube([10, 25, 10.5], center=true);
color("red")
rotate([0,0,25])
//translate([(-10.5)/2+0.45, -46.6, 0])
translate ([-4.8143, -46.7157, 0])
cube([10, 75, 10.5], center=true);
// et voila
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org