[OpenSCAD] Issue with scaling, increase face count for accuracy

Katt saideep.pavuluri at pet.hw.ac.uk
Fri Apr 6 10:21:59 EDT 2018


Hi guys;

I am using the following code to generate an stl image. 

//*******CODE START************//
n=5;

//nverts control smoothing of the cad model
nverts=100;

//scales the x-coordinate
scalex=1;

//Compute the 'y' for a given x, n
function f(x)= pow(x,n)/ (pow(x,n)+pow((1-x),n)) + 0.5;

//Generate a symmetric model
verts=concat([for(i=[0:nverts-1]) [scalex*i/nverts, f(i/nverts)]],
[for(i=[nverts-1:-1:0]) [scalex*i/nverts, -f(i/nverts)]] );

linear_extrude(height = 0.5){
//Join the vertices to form the required polygon    
polygon(verts);
}

nverts1 = 100;
scalex1 = -2;

function f1(x)=0.5;
verts1=concat([for(i=[0:nverts1-1]) [scalex1*i/nverts1, f1(i/nverts1)]],
[for(i=[nverts1-1:-1:0]) [scalex1*i/nverts1, -f1(i/nverts1)]] );

linear_extrude(height = 0.5){
polygon(verts1);
}

nverts2 = 100;
scalex2 = 2.0;

function f2(x)=1.5;
verts2=concat([for(i=[0:nverts2-1]) [0.99+scalex2*i/nverts2,
f2(i/nverts2)]], [for(i=[nverts2-1:-1:0]) [0.99+scalex2*i/nverts2,
-f2(i/nverts2)]] );

linear_extrude(height = 0.5){
polygon(verts2);
}

//*******CODE END************//


1. The stl shall ideally be symmetric and looks symmetric but when I zoom
close I see steps on one side but not on the other which means the stl is
not really symmetric. Why is this so and how to make it accurate? You can
see them at the curves.

2. The scale is imprecise. That is, for example, "scalex1 and scalex2" are
set to 2 (meaning the ends shall end at 1 and at 3) but they are only
approximate? What is causing this imperfection. 
Because of this, I had to use a scaling number 0.99 instead of 1 in the
following in the code adjusting segments else would disjoin the stl:
verts2=concat([for(i=[0:nverts2-1]) [*0.99*+scalex2*i/nverts2,
f2(i/nverts2)]], [for(i=[nverts2-1:-1:0]) [*0.99*+scalex2*i/nverts2,
-f2(i/nverts2)]] );

3. I would like to get a more precise geometry by probably increasing the
number of faces of the stl model. Any idea how to do it? 
<http://forum.openscad.org/file/t2047/fn.png> 
I am interested in the normal vectors on these faces and I am guessing that
they are approximate and not accurate enough. Any thoughts on this?

Thanks



--
Sent from: http://forum.openscad.org/



More information about the Discuss mailing list