discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Problem with rotate / translate

LB
L Boyd
Thu, Aug 27, 2015 1:35 PM

If what you are trying to do is rotate your gusset to place it on a member
with a different orientation, you need to be aware that rotate() always
rotates about the origin [0,0,0].

See the tread "rotating a cube around the center of the y-axis of the cube"
for more discussion of this.

--
View this message in context: http://forum.openscad.org/Problem-with-rotate-translate-tp13611p13622.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

If what you are trying to do is rotate your gusset to place it on a member with a different orientation, you need to be aware that rotate() always rotates about the origin [0,0,0]. See the tread "rotating a cube around the center of the y-axis of the cube" for more discussion of this. -- View this message in context: http://forum.openscad.org/Problem-with-rotate-translate-tp13611p13622.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Fri, Aug 28, 2015 9:54 AM

The first rotate and translate look like they're in the wrong order. If the
rotate goes first then it will rotate around the origin before translating
to a new position. This is where you should put your overall rotate/pos
transform IMHO.
However - you need to remember that all rotates occur around the origin. So
your shapes need to be balanced either side of the origin for rotates to act
equally. I've centered some shapes below and remixed your ordering a bit.
http://forum.openscad.org/file/n13626/gusset.png
// NOTE:
// - All measurements in mm
// - All frame gussets have a thickness of 6 mm (~0.25")
//  and a front-to-back (non-tube side to non-tube side) of 76 mm (~3").
// - A 25 mm (~1") gap between the inner gusset face and the welded tube
joint must exist.
// - Tube-facing edges must be concaved to the same diameter of the tubing
it will interface with.

// Set resolution of rounded objects
cyl_res = 100; // res for cylindrical cuts
plate_res = 720; // higher res for the plate
Delta = 0.1; // used to get clearance for F6 conversions

module gusset(innerradius, outerradius, thickness,
degreespan, face1dia, face2dia,
rotx, roty, rotz, transx, transy, transz)  {
translate([transx,transy,transz])
rotate([rotx,roty,rotz])
difference(){
// Gusset Plate
translate([0, 0, -thickness/2]) // center
rotate_extrude($fn = plate_res)
translate([outerradius - innerradius, 0, 0])
square([innerradius, thickness]);

	// Cut upper half off
	#translate([outerradius/2+face1dia, 0, 0])
		cube ([outerradius+Delta*2, (outerradius+Delta)*2, thickness+Delta*2],

center=true);
// Use a cylinder to make rounded surface
#translate([face1dia, 0, 0])
rotate([90,0,0])
cylinder(h=(outerradius+Delta)*2, r=face1dia, center=true, $fn =cyl_res);

	// Cover the lower half
	#rotate([0,0,-degreespan])
	translate([-outerradius/2-face2dia, 0, 0])
		cube ([outerradius+Delta, (outerradius+Delta)*2, thickness+Delta*2],

center=true);
// Use a cylinder to make rounded surface
#rotate([90,0,90+degreespan])
translate([face2dia, 0, 0])
cylinder(h=(outerradius+Delta)*2, r=face2dia, center=true, $fn =cyl_res);
}
}
// NOTE: The only thing you have to change is the fourth value on.
// The first three values are set, for your purposes.

// NOTE:
// innerradius = radius of inner curve
// outerradius = radius of outer curve
// thickness = thickness of gusset
// degreespan = width from one tube-facing edge to the other

// face1dia = diameter of tube on face 1
// face2dia = diameter of tube on face 2

// rotx = rotate around the x axis
// roty = rotate around the y axis
// rotz = rotate around the z axix

// transx = move along x axis
// transy = move along y axis
// transz = move along z axis

gusset(76,101,6, 45,12,12, 0,0,0,0,0,0);
//gusset(76,101,6, 45,12,12, 0,-90,0,0,0,30);

--
View this message in context: http://forum.openscad.org/Problem-with-rotate-translate-tp13611p13626.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

The first rotate and translate look like they're in the wrong order. If the rotate goes first then it will rotate around the origin *before* translating to a new position. This is where you should put your overall rotate/pos transform IMHO. However - you need to remember that all rotates occur around the origin. So your shapes need to be balanced either side of the origin for rotates to act equally. I've centered some shapes below and remixed your ordering a bit. <http://forum.openscad.org/file/n13626/gusset.png> // NOTE: // - All measurements in mm // - All frame gussets have a thickness of 6 mm (~0.25") // and a front-to-back (non-tube side to non-tube side) of 76 mm (~3"). // - A 25 mm (~1") gap between the inner gusset face and the welded tube joint must exist. // - Tube-facing edges must be concaved to the same diameter of the tubing it will interface with. // Set resolution of rounded objects cyl_res = 100; // res for cylindrical cuts plate_res = 720; // higher res for the plate Delta = 0.1; // used to get clearance for F6 conversions module gusset(innerradius, outerradius, thickness, degreespan, face1dia, face2dia, rotx, roty, rotz, transx, transy, transz) { translate([transx,transy,transz]) rotate([rotx,roty,rotz]) difference(){ // Gusset Plate translate([0, 0, -thickness/2]) // center rotate_extrude($fn = plate_res) translate([outerradius - innerradius, 0, 0]) square([innerradius, thickness]); // Cut upper half off #translate([outerradius/2+face1dia, 0, 0]) cube ([outerradius+Delta*2, (outerradius+Delta)*2, thickness+Delta*2], center=true); // Use a cylinder to make rounded surface #translate([face1dia, 0, 0]) rotate([90,0,0]) cylinder(h=(outerradius+Delta)*2, r=face1dia, center=true, $fn =cyl_res); // Cover the lower half #rotate([0,0,-degreespan]) translate([-outerradius/2-face2dia, 0, 0]) cube ([outerradius+Delta, (outerradius+Delta)*2, thickness+Delta*2], center=true); // Use a cylinder to make rounded surface #rotate([90,0,90+degreespan]) translate([face2dia, 0, 0]) cylinder(h=(outerradius+Delta)*2, r=face2dia, center=true, $fn =cyl_res); } } // NOTE: The only thing you have to change is the fourth value on. // The first three values are set, for your purposes. // NOTE: // innerradius = radius of inner curve // outerradius = radius of outer curve // thickness = thickness of gusset // degreespan = width from one tube-facing edge to the other // face1dia = diameter of tube on face 1 // face2dia = diameter of tube on face 2 // rotx = rotate around the x axis // roty = rotate around the y axis // rotz = rotate around the z axix // transx = move along x axis // transy = move along y axis // transz = move along z axis gusset(76,101,6, 45,12,12, 0,0,0,0,0,0); //gusset(76,101,6, 45,12,12, 0,-90,0,0,0,30); -- View this message in context: http://forum.openscad.org/Problem-with-rotate-translate-tp13611p13626.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Fri, Aug 28, 2015 10:03 AM

Here is a different factoring where you can cut any shape you want using the
tubes.

// different factoring where the plate could be a different object. e.g.
Tubing, or double wall.
module tube_cut(innerradius, outerradius,
degreespan, face1dia, face2dia )  {
// Cut upper half off
#translate([outerradius/2+face1dia, 0, 0])
cube ([outerradius+Delta*2, (outerradius+Delta)*2, (face1dia+Delta)*2],
center=true);
// Use a cylinder to make rounded surface
#translate([face1dia, 0, 0])
rotate([90,0,0])
cylinder(h=(outerradius+Delta)*2, r=face1dia, center=true, $fn =cyl_res);

// Cover the lower half
#rotate([0,0,-degreespan])
translate([-outerradius/2-face2dia, 0, 0])
	cube ([outerradius+Delta, (outerradius+Delta)*2, (face2dia+Delta)*2],

center=true);
// Use a cylinder to make rounded surface
#rotate([90,0,90+degreespan])
translate([face2dia, 0, 0])
cylinder(h=(outerradius+Delta)*2, r=face2dia, center=true, $fn =cyl_res);
}

module plate(thickness, outerradius, innerradius)  {
// Gusset Plate
translate([0, 0, -thickness/2]) // center
rotate_extrude($fn = plate_res)
translate([outerradius - innerradius, 0, 0])
square([innerradius, thickness]);
}

//----------------
module plate_gusset(innerradius, outerradius, thickness,
degreespan, face1dia, face2dia,
rotx, roty, rotz, transx, transy, transz)  {
translate([transx,transy,transz])
rotate([rotx,roty,rotz])
difference(){
plate(thickness, outerradius, innerradius);
tube_cut(innerradius, outerradius, degreespan, face1dia, face2dia);
}
}

plate_gusset(76,101,6, 45,12,12, 0,0,0,0,0,30);

--
View this message in context: http://forum.openscad.org/Problem-with-rotate-translate-tp13611p13627.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Here is a different factoring where you can cut any shape you want using the tubes. // different factoring where the plate could be a different object. e.g. Tubing, or double wall. module tube_cut(innerradius, outerradius, degreespan, face1dia, face2dia ) { // Cut upper half off #translate([outerradius/2+face1dia, 0, 0]) cube ([outerradius+Delta*2, (outerradius+Delta)*2, (face1dia+Delta)*2], center=true); // Use a cylinder to make rounded surface #translate([face1dia, 0, 0]) rotate([90,0,0]) cylinder(h=(outerradius+Delta)*2, r=face1dia, center=true, $fn =cyl_res); // Cover the lower half #rotate([0,0,-degreespan]) translate([-outerradius/2-face2dia, 0, 0]) cube ([outerradius+Delta, (outerradius+Delta)*2, (face2dia+Delta)*2], center=true); // Use a cylinder to make rounded surface #rotate([90,0,90+degreespan]) translate([face2dia, 0, 0]) cylinder(h=(outerradius+Delta)*2, r=face2dia, center=true, $fn =cyl_res); } module plate(thickness, outerradius, innerradius) { // Gusset Plate translate([0, 0, -thickness/2]) // center rotate_extrude($fn = plate_res) translate([outerradius - innerradius, 0, 0]) square([innerradius, thickness]); } //---------------- module plate_gusset(innerradius, outerradius, thickness, degreespan, face1dia, face2dia, rotx, roty, rotz, transx, transy, transz) { translate([transx,transy,transz]) rotate([rotx,roty,rotz]) difference(){ plate(thickness, outerradius, innerradius); tube_cut(innerradius, outerradius, degreespan, face1dia, face2dia); } } plate_gusset(76,101,6, 45,12,12, 0,0,0,0,0,30); -- View this message in context: http://forum.openscad.org/Problem-with-rotate-translate-tp13611p13627.html Sent from the OpenSCAD mailing list archive at Nabble.com.