Confused as how a this could happen

classic Classic list List threaded Threaded
44 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Confused as how a this could happen

adrian
I was writing a module to replace rotate_extrude() so that I could deal with the issue that I mentioned in the Does rotate_extrude angle property allow for values that don't divide 360 evenly? thread.  However, I got some weird error which I can only describe as a rounding error, but I am not exactly positive that it is.

Here is the full executable code:
function is_matrix(x)  = len(x) != undef && (x[0] != x[0][0] || len(x) != len(str(x)));
function is_number(x)  = len(x) == undef &&  (-inf <= x && x <= +inf);
inf=1/0;
function is_inf(x)     = x == -inf || x == +inf;

// ASSERT
//
//   Asserts that x is true.  If false, then echo msg, otherwise do nothing.
module ASSERT(x, msg)
{
    if (!x)
    {
        if (msg == undef)
        {
            echo(str("<span style='background-color: red; color: white'> ASSERT FAILURE: </span>&nbsp;<span style='color: red'>No message.</span>"));
        }
        else
        {
            echo(str("<span style='background-color: red; color: white'> ASSERT FAILURE: </span>&nbsp;<span style='color: red'>", msg, "</span>"));
        }
    }
}

wedge_below_xy = 0;
wedge_above_xy = 1;
wedge_centred  = 2;

// wedge
//
//  Generates a wedge which is off to the right of the y-axis and is centred on
//  the x-axis.
//
//  Primary purporse of wedge is to produce a wedge for intersecting with an
//  object.
//
// size
//   - is matrix then
//       length = size[0]*2 (y-axis)
//       width  = size[1] (x-axis)
//       height = size[2] (z-axis)
//       angle  = has no meaning in this context
//   - is a value then
//       specifies the half base size along xy-plane
//       length = size*2 (y-axis)
//       width  = size (x-axis)
//       - if angle is undefined then
//           height = size.
//         else
//           height = tan(angle)*size.
// type
//   - is wedge_centred then wedge is centred around the xy-plane
//     (See Figure 1)
//   - is wedge_above_xy then wedge is above the xy-plane
//     (See Figure 2)
//   - is wedge_below_xy then wedge is below the xy-plane
//     (See Figure 2)
//
//  E.g. Figure 1:  wedge_centred
//
//  y-axis                     z-axis            
//                                               
//    |<-width->                 |               
//    |________.   ___           |           ___ 
//    |        |    ^            |       /|   ^  
//    |        |    |            |      / |   |  
//    |        |    |            |     /  |   |  
//    |        |    |            |    /   |   |  
//    |        | length/2        |   /    | height
//    |        |    |            |  /     |   |  
//    |        |    |            | /      |   |  
//    |        |    v            |/       |   |  
//  --+--------+------ x-axis ---+--------+---|--
//    |        |                 |\       |   |  
//    |        |                 | \      |   |  
//    |        |                 |  \     |   |  
//    |        |                 |   \    |   |  
//    |        |                 |    \   |   |  
//    |        |                 |     \  |   |  
//    |        |                 |      \ |   |  
//    |________|                 |       \|  _v_ 
//    |                          |               
//    |                          |               
//
//  E.g. Figure 2:  wedge_above_xy and wedge_below_xy
//
//  y-axis                     z-axis                   z-axis            
//                                                                        
//    |<-width->                 |                        |               
//    |________.   ___           |           ___          |
//    |        |    ^            |       /|   ^           |
//    |        |    |            |      / |   |           |
//    |        |    |            |     /  |   |           |
//    |        |    |            |    /   |   |           |
//    |        | length/2        |   /    | height        |
//    |        |    |            |  /     |   |           |
//    |        |    |            | /      |   |           |
//    |        |    v            |/       |   v           |
//  --+--------+------ x-axis ---+--------+------      ---+--------+------
//    |        |                 |                        |\       |   ^  
//    |        |                 |                        | \      |   |  
//    |        |                 |                        |  \     |   |  
//    |        |                 |                        |   \    | height
//    |        |                 |                        |    \   |   |  
//    |        |                 |                        |     \  |   |  
//    |        |                 |                        |      \ |   |  
//    |________|                 |                        |       \|  _v_ 
//    |                          |                        |               
//    |                          |                        |               
//
module wedge(size, angle, type)
{
    ASSERT(type != undef, "Specify type of wedge");
    if (is_matrix(size))
    {
        w(size[0], size[1], size[2], type);
    }
    else
    {
        if (angle == undef)
        {
            w(size, size, size, type);
        }
        else
        {
            w(size, size, tan(angle)*size, type);
        }
    }

    module w(l0, w0, h0, type)
    {
        wedge_faces = [[0,1,2,3],[3,5,4,0],[4,1,0],[2,5,3],[4,5,2,1]];
        l=l0+0;
        w=w0+0;
        if (type == wedge_centred)
        {
            h=h0/2;
            polyhedron(
                [[0,-l,0],[w,-l,-h],[w,l,-h],[0,l,0],[w,-l,h],[w,l,h]],
                wedge_faces
            );
        }
        else if (type == wedge_below_xy)
        {
            h=h0;
            polyhedron(
                [[0,-l,0],[w,-l,-h],[w,l,-h],[0,l,0],[w,-l,0],[w,l,0]],
                wedge_faces
            );
        }
        else if (type == wedge_above_xy)
        {
            h=h0;
            polyhedron(
                [[0,-l,0],[w,-l,0],[w,l,0],[0,l,0],[w,-l,h],[w,l,h]],
                wedge_faces
            );
        }
        else
        {
            ASSERT(false, "Wedge type not valid value when calling module wedge().");
        }
    }
}


// wedge_extrude
//
//  Extrude a wedge object for building extrusion arcs.  Extrusion is along the
//  z-axis.
//
// angle
//   - angle of the wedge.
// radius
//   - bounding circle's radius around the z-axis.
// convexity
//   - passed along to linear_extrude().
// type
//   - wedge type.  See module wedge().
//
module wedge_extrude(angle, radius, convexity, type)
{
    segment_height = radius*tan(angle);
    if (type == wedge_centred)
    {
        intersection()
        {
            translate([0,0,-segment_height/2])
                linear_extrude(height=segment_height, convexity=convexity)
                    children();
            wedge(radius, angle, wedge_centred);
        }
    }
    else if (type == wedge_above_xy)
    {
        intersection()
        {
            linear_extrude(height=segment_height, convexity=convexity)
                children();
            wedge(radius, angle, wedge_above_xy);
        }
    }
    else if(type == wedge_below_xy)
    {
        intersection()
        {
            translate([0,0,-segment_height])
                linear_extrude(height=segment_height, convexity=convexity)
                    children();
            wedge(radius, angle, wedge_below_xy);
        }
    }
    else
    {
        ASSERT(false, "Wedge type not valid value when calling module wedge_extrude().");
    }
}

// rotate_extrude_
//
//  A possible replacement idea for module rotate_extrude().
//
// convexity
//   - Passed to rotate_extrude() and linear_extrude() modules.
// angle
//   - Angle to sweep around.
// max_angle
//   - Max segment angle.
// radius
//   - Bounding circle radius around z-axis. 
module rotate_extrude_(convexity = 2, angle = 360, max_angle = 0, radius, max_angle_exact = false)
{
    ASSERT(is_number(radius) && !is_inf(radius)
    , "radius must be the minimum, non-infinite number that would enclose the object extruding.");
    echo(max_angle=max_angle);
    if (max_angle == 0)
    {
        // this extends line till it meets with other line
        echo("A");
        a = angle/2;
        rotate([90,0,angle])
            wedge_extrude(a, radius, convexity, wedge_above_xy)
                children();
        rotate([90,0,angle])
            rotate(angle, [0,-1,0])
                wedge_extrude(a, radius, convexity, wedge_below_xy)
                    children();
    }
    else
    {
        // this attempts to curve, never exceding radius around turn
        // this uses rotate_extrude
        echo("B");
		
		if (max_angle_exact)
		{
			segment_angle = max_angle;
			segment_count_full = segment_angle == 0 ? 0 : angle/segment_angle;
			segment_count = floor(segment_count_full);
			segment_remaining = segment_count_full - segment_count;

			sweep_angle = segment_count * segment_angle;
			sweep_remaining_angle = segment_remaining * segment_angle;

			echo(
				"B1",
				angle=angle,
				max_angle=max_angle,
				segment_angle=segment_angle,
				segment_count_full=segment_count_full,
				segment_count=segment_count,
				segment_remaining=segment_remaining,
				sweep_angle=sweep_angle,
				sweep_remaining_angle=sweep_remaining_angle
			);

			extrude_using_wedge_extrude(segment_count, segment_angle, sweep_remaining_angle, radius, convexity)
				children();
			extrude_end_segments(angle, sweep_angle, sweep_remaining_angle, radius, convexity)
				children();
		}
		else
		{
			next_angle = 360/floor(360/max_angle);
			fn = next_angle > max_angle
				? (floor(360/max_angle)+1)
				: floor(360/max_angle);
			segment_angle = 360/fn;
			segment_count_full = segment_angle == 0 ? 0 : angle/segment_angle;
			segment_count = floor(segment_count_full);
			segment_remaining = segment_count_full - segment_count;

			sweep_angle = segment_count * segment_angle;
			sweep_remaining_angle = segment_remaining * segment_angle;

			echo(
				"B2",
				fn=fn,
				angle=angle,
				next_angle=next_angle,
				max_angle=max_angle,
				segment_angle=segment_angle,
				segment_count_full=segment_count_full,
				segment_count=segment_count,
				segment_remaining=segment_remaining,
				sweep_angle=sweep_angle,
				sweep_remaining_angle=sweep_remaining_angle
			);

			extrude_using_rotate_extrude(angle, sweep_angle, segment_angle, segment_count, fn, radius, convexity)
				children();
			extrude_end_segments(angle, sweep_angle, sweep_remaining_angle, radius, convexity)
				children();
		}
    }

	// end point extrusions
	module extrude_end_segments(angle, sweep_angle, sweep_remaining_angle, radius, convexity)
	{
        echo("E");
		segment_height = radius*tan(sweep_remaining_angle / 2);
		rotate(angle/2)
		if(1) // rotate both object without union()
		{
			rotate([90,0,-(sweep_angle/2+sweep_remaining_angle/4)])
				wedge_extrude(sweep_remaining_angle/2, radius, convexity, wedge_centred)
					children();
			rotate([90,0,(sweep_angle/2+sweep_remaining_angle/4)])            
				wedge_extrude(sweep_remaining_angle/2, radius, convexity, wedge_centred)
					children();
		}
	}

	module extrude_using_rotate_extrude(angle, sweep_angle, segment_angle, segment_count, fn, radius, convexity)
	{
        echo("C0");
		rotate_offset = 
			segment_count % 2 == 0
				? segment_angle / 2
				: 0;
		rotate_flat = fn % 2 == 0 ? segment_angle / 2 : 0;
		rotate(angle/2)
		intersection()
		{
			rotate(rotate_flat+rotate_offset)
			rotate_extrude(convexity=convexity, $fn=fn)
				children();
			rotate([90,0,0*rotate_offset])
				wedge(radius, sweep_angle, wedge_centred);
		}
        echo("C1");
	}

	module extrude_using_wedge_extrude(segment_count, segment_angle, sweep_remaining_angle, radius, convexity)
	{
        echo("D");
		rotate(90, [1,0,0])
		for(i=[1:1:segment_count])
		{
			rotate(segment_angle*(i-.5)+sweep_remaining_angle/2, [0,1,0])
			wedge_extrude(segment_angle, radius, convexity, wedge_centred)
				children();
		}
	}
}

rotate_extrude_(angle=45, max_angle=16, radius=1, convexity=5, max_angle_exact=0)
    arrow_2d(1, .5, .25);

module arrow_2d(l,w,a)
{
    polygon([[0,0],[w,0],[w,l-a],[w*1.3,l-a],[0,l]]);
}


and this is what I'm getting at the interface between the rotate_extrude() and the extrude_end_segments():

interface

Note that the extrude_end_segments() is producing an object that is not the same size as the rotate_extrude().  However, since these are only supposed to be rotations, should there be that much of a change in size?  Looks to be in the 1-0.1 unit range.  Is this indeed a rounding error?

Thanks,


A
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

cacb
On 2017-01-09 03:51, adrian wrote:
> I was writing a module to replace rotate_extrude() so that I could deal
> with
> the issue that I mentioned in the  Does rotate_extrude angle property
> allow
> for values that don't divide 360 evenly?

I don't understand the premise of the problem. Where does this idea of
"values that don't divide 360 evenly" come from? That is just weird.
There is no such limitation, or at least there should not be. The only
thing is that in versions prior to 2016.xx, the angle parameter is
silently ignored and assumed to be 360.

Just use whatever angle you want with rotate_extrude. Granted, I have
not tried OpenSCAD 2016.xx yet, so if there is an issue it should be
identified and fixed. I think a simple example demonstrating the problem
should be provided, for example:

rotate_extrude(angle=57.295779513082320876798154814105)
translate([50,0,0]) circle(10);

Doesn't it work in 2016.xx ?

Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

Parkinbot
cacb wrote
rotate_extrude(angle=57.295779513082320876798154814105)
translate([50,0,0]) circle(10);

Doesn't it work in 2016.xx ?
well, you won't get more than 7 digits (single) or so resolved, but of course it works.

Where is the problem to download a 2016.xx and test it?
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

cacb
On 2017-01-09 11:17, Parkinbot wrote:
>
> Where is the problem to download a 2016.xx and test it?

The problem is not here. I have been using other software recently...
:-) I just figured the link to 2016.xx was at the bottom of the download
page. As could be expected my little example works, so the whole issue
is a non-problem.

Carsten Arnholm





_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

Parkinbot
cacb wrote
the whole issue is a non-problem.
Yes and no. A solution based on sweep() can easily be extended to something more general than just a rotate_extrude. Remember our discussion about threads.

Adrian, this is your code using 2016.xx, some odd angle and an arbitrary resolution.  
rotate_extrude(angle = 42.234, $fn = 200) arrow_2d(1, .5, .25);
module arrow_2d(l,w,a)  polygon([[0,0],[w,0],[w,l-a],[w*1.3,l-a],[0,l]]);
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

cacb
On 2017-01-09 12:07, Parkinbot wrote:
> cacb wrote
>> the whole issue is a non-problem.
>
> Yes and no. A solution based on sweep() can easily be extended to
> something
> more general than just a rotate_extrude. Remember our discussion about
> threads <http://www.thingiverse.com/thing:1659079>  .

The non-problem referred to the value of the angle parameter.

Sure, a general sweep would be extremely useful, I agree. However, when
talking specifically about threads, one can imagine extending
rotate_extrude to take a pitch parameter and allow angles spanning
several whole revolutions. The model below was created using my own
variant of rotate_extrude (on top of carve), rotating 15*360 degrees and
with a suitable pitch. It is smart enough to protest if self
intersections will occur, so in practice it works.

http://www.thingiverse.com/thing:1445033


Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
This post was updated on .
In reply to this post by cacb
cacb wrote
On 2017-01-09 03:51, adrian wrote:
> I was writing a module to replace rotate_extrude() so that I could deal
> with
> the issue that I mentioned in the  Does rotate_extrude angle property
> allow
> for values that don't divide 360 evenly?

I don't understand the premise of the problem. Where does this idea of
"values that don't divide 360 evenly" come from? That is just weird.
There is no such limitation, or at least there should not be. The only
thing is that in versions prior to 2016.xx, the angle parameter is
silently ignored and assumed to be 360.
The premise is that $fn must be an integer, so you cannot have a rotate_extrude produce an extrusion that doesn't result in a whole number of angled segments.

cacb wrote
Just use whatever angle you want with rotate_extrude. Granted, I have
not tried OpenSCAD 2016.xx yet, so if there is an issue it should be
identified and fixed. I think a simple example demonstrating the problem
should be provided, for example:

rotate_extrude(angle=57.295779513082320876798154814105)
translate([50,0,0]) circle(10);

Doesn't it work in 2016.xx ?
I never got a clear answer if on either end of the extrusion would have a complete, 100% scaled, 2d representation of the original.
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
In reply to this post by Parkinbot
Parkinbot wrote
Where is the problem to download a 2016.xx and test it?
I've not bothered as yet because afaik, I would have to build it and I'm just too lazy.
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
In reply to this post by cacb
cacb wrote
On 2017-01-09 11:17, Parkinbot wrote:
>
> Where is the problem to download a 2016.xx and test it?

The problem is not here. I have been using other software recently...
:-) I just figured the link to 2016.xx was at the bottom of the download
page. As could be expected my little example works, so the whole issue
is a non-problem.
Good to know about that.  Never bothered to go down the page recently.  I'll try it out. :)
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

Ronaldo
In reply to this post by adrian
adrian wrote
The premise is that $fn must be an integer, so you cannot have a rotate_extrude produce an extrusion that doesn't result in a whole number of angled segments.
Your premise is wrong. You may assign a fraction value to $fn: it will be adjusted to an integer (with floor, I guess). If an angle is specified in rotate_extrude, $fn is adjusted in order to ensure that the total angle is met. See this example from above and bellow to confirm a perfect match:
color("blue")
translate([0,0,-7])
rotate_extrude(r=10, $fn=14.5)
    translate([10,0]) square(5,center=true);

rotate_extrude(r=10, angle=360/7, $fn=14)
    translate([10,0]) square(5,center=true);

color("red")
translate([0,0,7])
rotate_extrude(r=10, angle=360/7, $fn=18.5)
    translate([10,0]) square(5,center=true);
 
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
Ronaldo wrote
adrian wrote
The premise is that $fn must be an integer, so you cannot have a rotate_extrude produce an extrusion that doesn't result in a whole number of angled segments.
Your premise is wrong. You may assign a fraction value to $fn: it will be adjusted to an integer (with floor, I guess). If an angle is specified in rotate_extrude, $fn is adjusted in order to ensure that the total angle is met. See this example from above and bellow to confirm a perfect match:
My premise wasn't wrong, but my wording was.  ;) Yes, I know that $fn can be a floating point number, but it will be coerced into a integer in the context that I was referring to.
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

cacb
In reply to this post by adrian
On 2017-01-09 15:00, adrian wrote:
> cacb wrote
> The premise is that $fn must be an integer, so you cannot have a
> rotate_extrude produce an extrusion that doesn't result in a whole
> number of
> angled segments.

When you cut a cake, you will always get a whole number of slices, there
is simply no other way....

Carsten Arnholm





_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
In reply to this post by cacb
So given the following:
module test1(angle, max_angle, use_mine)
{
    if (use_mine)
    {
        rotate_extrude_(angle=angle, max_angle=max_angle, radius=1, convexity=5, max_angle_exact=1)
            arrow_2d(1, .5, .25);
    }
    else
    {
        rotate_extrude(angle=angle, $fn=360/max_angle, radius=1, convexity=5, max_angle_exact=1)
            arrow_2d(1, .5, .25);
    }
    color("red")
    if (1)
    {
        rotate([90, 0, 0])
        linear_extrude(height=1, convexity=5)
            arrow_2d(1, .5, .25);
        rotate([90, 0, angle])
        translate([0,0,-1])
        linear_extrude(height=1, convexity=5)
            arrow_2d(1, .5, .25);
    }
}
test1(42.3, 10, true);
I would get this:


Changing the last parameter in test1() to false, I would get this:

If you notice, in my implementation, the extrusion is broken up into 6 parts, 4 of which are 10 degrees in size and the other 2, the remaining 2 being 2.3/2 (1.15) in size.  In the builtin, it is only 4 segments, presumably 10.575 degrees in size.

I'm not saying anything is wrong with that, even if you can't control the maximum rotation segment angle, but there is still a matter of the fit of my implementation that I find odd.  AFAICS, this should fit properly and I'm trying to confirm that this is due to a rounding error or not.
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
In reply to this post by cacb
cacb wrote
On 2017-01-09 15:00, adrian wrote:
> cacb wrote
> The premise is that $fn must be an integer, so you cannot have a
> rotate_extrude produce an extrusion that doesn't result in a whole
> number of
> angled segments.

When you cut a cake, you will always get a whole number of slices, there
is simply no other way....
Depends on your definition of "whole".  You can't get half a piece as each piece is a whole piece, but there is no stipulation that each piece must be exactly the same size. I could cut it into 10 slices of totally different sizes.  
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
adrian wrote
cacb wrote
On 2017-01-09 15:00, adrian wrote:
> cacb wrote
> The premise is that $fn must be an integer, so you cannot have a
> rotate_extrude produce an extrusion that doesn't result in a whole
> number of
> angled segments.

When you cut a cake, you will always get a whole number of slices, there
is simply no other way....
Depends on your definition of "whole".  You can't get half a piece as each piece is a whole piece, but there is no stipulation that each piece must be exactly the same size. I could cut it into 10 slices of totally different sizes.
In any case, this question has gone beyond the original.  I'm trying to determine why there seems to be fitting errors and if they are due to something I did or just rounding errors.
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

nophead
>I was writing a module to replace rotate_extrude() so that I could deal with the issue that I mentioned in the Does rotate_extrude angle property allow for values that don't divide 360 evenly? thread.

I still don't understand what your original issue is so I can't understand what your replacement module is trying to do.

The angle value for rotate_extruder does not need to divide evenly into 360. The end of the object should have exactly the angle you specify. Is that the not the case? Or is it something to do with how $fn creates the facets that you find wrong?

On 9 January 2017 at 15:29, adrian <[hidden email]> wrote:
adrian wrote
>
> cacb wrote
>> On 2017-01-09 15:00, adrian wrote:
>>> cacb wrote
>>> The premise is that $fn must be an integer, so you cannot have a
>>> rotate_extrude produce an extrusion that doesn't result in a whole
>>> number of
>>> angled segments.
>>
>> When you cut a cake, you will always get a whole number of slices, there
>> is simply no other way....
> Depends on your definition of "whole".  You can't get half a piece as each
> piece is a whole piece, but there is no stipulation that each piece must
> be exactly the same size. I could cut it into 10 slices of totally
> different sizes.

In any case, this question has gone beyond the original.  I'm trying to
determine why there seems to be fitting errors and if they are due to
something I did or just rounding errors.



--
View this message in context: http://forum.openscad.org/Confused-as-how-a-this-could-happen-tp19958p19985.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

adrian
The original issue is no longer an issue.  Turns out that it will force the correct angle segment size in 2016 which is close to 360/$fn such that it will evenly divide the sweeping angle.

I was in 2015 so there wasn't an angle parameter, so I was trying to make something that would do the same thing.  That is what the above programme does.  The issue that I am pointing out here is only related to that thread because that is how this started.  Ignore that thread now.

The issue that I am having is that I am trying to determine why the code that I wrote doesn't result in sections that fit together exactly.  Is this not working because the multiple transforms are causing the coordinate of the objects to drift enough to see the issue that can be seen in the above images where the surfaces are out of alignment?

Thanks,


A
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

nophead
Adding a # to extrude_end_segments shows that they overlap the middle of the object, angle wise. So I think that might be why there is a step radially.
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

nophead
I am struggling to understand why it is so complicated. Why do you do the end bits separately and not just intersect some oversized wedges with rotate_extrude?

On 9 January 2017 at 19:35, nophead <[hidden email]> wrote:
Adding a # to extrude_end_segments shows that they overlap the middle of the
object, angle wise. So I think that might be why there is a step radially.



--
View this message in context: http://forum.openscad.org/Confused-as-how-a-this-could-happen-tp19958p19991.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Confused as how a this could happen

nophead
Something like this ?:

module pie_slice(r, start_angle, end_angle) {
    R = r * sqrt(2) + 1;
    a0 = (4 * start_angle + 0 * end_angle) / 4;
    a1 = (3 * start_angle + 1 * end_angle) / 4;
    a2 = (2 * start_angle + 2 * end_angle) / 4;
    a3 = (1 * start_angle + 3 * end_angle) / 4;
    a4 = (0 * start_angle + 4 * end_angle) / 4;
    if(end_angle > start_angle)
        intersection() {
        circle(r);
        polygon([
            [0,0],
            [R * cos(a0), R * sin(a0)],
            [R * cos(a1), R * sin(a1)],
            [R * cos(a2), R * sin(a2)],
            [R * cos(a3), R * sin(a3)],
            [R * cos(a4), R * sin(a4)],
       ]);
    }
}

$fn = 32;

module rotate_extrude_angle(angle, radius, convexity)
    intersection() {
        rotate_extrude(convexity = convexity)
            children();
       
        hull()
            linear_extrude(height = 1, convexity = convexity)
                pie_slice(radius, 0, angle);
                   
    }


rotate_extrude_angle(angle=45, radius=1, convexity=5)
    arrow_2d(1, .5, .25);

module arrow_2d(l,w,a)
{
    polygon([[0,0],[w,0],[w,l-a],[w*1.3,l-a],[0,l]]);
}



On 9 January 2017 at 20:58, nop head <[hidden email]> wrote:
I am struggling to understand why it is so complicated. Why do you do the end bits separately and not just intersect some oversized wedges with rotate_extrude?

On 9 January 2017 at 19:35, nophead <[hidden email]> wrote:
Adding a # to extrude_end_segments shows that they overlap the middle of the
object, angle wise. So I think that might be why there is a step radially.



--
View this message in context: http://forum.openscad.org/Confused-as-how-a-this-could-happen-tp19958p19991.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
123