OpenSCAD problem

17 views
Skip to first unread message

Iain Yarnall

unread,
Oct 11, 2016, 3:47:16 PM10/11/16
to North East Makers
Hiya,

I'm trying to draw/code an FPV camera mount in OpenSCAD and I've come to a sticking point.

I've done the camera body and lens, rotated them and removed them from a block to make a camera shaped impression I can put zip ties round.

The problem I've got is the hole for the wires.  I'm thinking I need to make a polyhedron from 4 points on the back of the rotated camera to 4 points on the block which hasn't been rotated.

Is there an easy solution to this or do I just need to do the geometry to work out the 4 points on the back of the camera?


i.e. I'm looking to make a hole that replaces the "//REPLACE ME" lines of code below that goes from the corner of the camera to the middle of the rear face of the block.

Cheers,

Iain.


echo(version=version());

//Frame
Layerheight=10;

// Camera
BodyWid = 19;
BodyDep = 10;
BodyHei = 19;
LensRad1 = 7.5;
LensLen1 = 12;
LensRad2 = 9.5;
LensLen2 = 8;
LensX = 10;
LensY = 10;
CableHoleX = 6;
CableHoleY = 4;
CableHoleZ = 20;

// Zip Ties
TieWidth = 3;
TieThick = 2;
LensTieOffsetFromLens = 3;
CamTieRad = 18;

//Main Block
BlockWidth = CamTieRad*2;
BlockLength = Layerheight*2;
BlockHeight = 30;


difference()
{
    // Main Block with Cable Tie Loop
    translate([0,-5,-5])
    {
        difference()
        {
            cube([BlockWidth,BlockLength,BlockHeight]);
            translate([BlockWidth/2,BlockLength-Layerheight,0])
            {
                rotate([-90,0,0])
                difference()
                {
                    cylinder(r=CamTieRad+TieThick,h=TieWidth);
                    cylinder(r=CamTieRad,h=TieWidth);
                }
            }
        }
    }
    
    //  Camera and Cable Tie Loop
    translate ([BlockWidth/2-(BodyWid/2) ,5,0])
    {
        rotate([-10,0,0])
        {
            cube([BodyHei, BodyWid, BodyDep]);

            translate ([LensX,LensY,BodyDep])
            {
                cylinder(r=LensRad1,h=LensLen1);
            }
            translate ([LensX,LensY,BodyDep+LensLen1])
            {
                cylinder(r=LensRad2,h=LensLen2);
            }
            translate ([BodyWid-CableHoleX,0,-CableHoleZ]) // REPLACE ME
            {
                cube([CableHoleX, CableHoleY, CableHoleZ]); // REPLACE ME
            }

            translate([LensX,LensY,BodyDep+LensLen1/2-(TieWidth/2)])
            {
                difference()
                {
                    cylinder(r=LensRad1+LensTieOffsetFromLens+TieThick,h=TieWidth);
                    cylinder(r=LensRad1+LensTieOffsetFromLens,h=TieWidth);
                }
            }
        }
    }
}

Dan Nixon

unread,
Oct 11, 2016, 4:13:44 PM10/11/16
to north-ea...@googlegroups.com
I'm not convinced I fully understand what you mean geometrically (even from opening the design), but is the general issue that you want to generate geometry that will be subtracted to form a cutout and said geometry depends on both the position of the mount and the camera?

In which case why can't you just separate the rotation of the camera into a module using children() and apply the same rotation to a cube that you can then subtract from the existing geometry.

Also you really need to fix your precision issues if you actually want to fix this. It manifests as "Z-fighting" when you rotate the design and is a result of floating point precision errors when you subtract exactly the correct amount when at the edge of the shape, rather than 0.1mm more.

It is possible that when the full GCAL render is done that it won't be an issue, but it is better to not allow it to become one.

Dan

--

You received this message because you are subscribed to the Google Groups "North East Makers" group.

To unsubscribe from this group and stop receiving emails from it, send an email to north-east-mak...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Iain Yarnall

unread,
Oct 11, 2016, 4:35:25 PM10/11/16
to North East Makers
There's a hole from the bottom left of the camera to the back of the main block.  Currently it's perpendicular to the camera and shares the rotation and comes out of the back of the main block relative to the camera.

I want to make it to come out the middle of back face the block regardless of the position and orientation of the camera.  I was thinking if I could do that, I could move the camera around to the desired position/angle and the wire would always come out at the same point on the block to match the hole on my frame.  If I rotate a cube then that rotation would change every time I change either the position or the angle of the camera so trying to avoid that for now.

The full render does seem to display correctly without the precision correction.  No idea how that converts into the final stl though!  I'll sort that if I need to once I've got the shape I'm after.  I've had rendering issues before for different reasons so getting quite used to pressing F6 now!

Cheers,

Iain.

Dan Nixon

unread,
Oct 11, 2016, 4:48:05 PM10/11/16
to north-ea...@googlegroups.com
The STL is generated from the full render, which is potentially a very computationally intensive process hence why there is the much cheaper preview and full render is a manual operation.
As the preview relies mostly on fast spatial calculations for GPU rendering you are more likely to get these artefacts.
I'm not sure what the precision of the CGAL renderer is but if you managed to get an error (most likely an accumulated error) that was greater than this precision then you could have issues in the rendered design too (but this is probably unlikely).

(and when I said GCAL I actually meant CGAL)

Dan

Dan Nixon

unread,
Oct 11, 2016, 4:52:47 PM10/11/16
to North East Makers
I'm not sure what the issue is then, why couldn't you just move the cube (contextually, not spatially) that denotes the cable hole so that it is not a sub-geometry of the camera?

Dan

Iain Yarnall

unread,
Oct 11, 2016, 5:05:40 PM10/11/16
to North East Makers
The problem is that one end of the cube is in the sub-geometry of the camera (or at least translated in some way) and the other end is in the sub-geometry of the main block with no translation/rotation.

I might be missing something simple here.


Cheers,

Iain.


Iain Yarnall

unread,
Oct 11, 2016, 6:00:33 PM10/11/16
to North East Makers
Solved!!

I just needed to use Hull() with 2 cubes, making sure one of them followed the same transformation as the camera!

Cheers,

Iain.



Reply all
Reply to author
Forward
0 new messages