POV-Ray : Newsgroups : povray.advanced-users : How to do a fill in Server Time
26 Nov 2024 04:34:20 EST (-0500)
  How to do a fill in (Message 1 to 9 of 9)  
From: Geoff Wedig
Subject: How to do a fill in
Date: 17 Jan 2001 10:46:51
Message: <3a65be6b@news.povray.org>
I have a set of points on the XY plane which have a clockwise order to form
a shape.  I want to fill this shape with something.  I can't use a prism
object for this purpose as it will eventually add a height element.  Does
anyone know how to generate a mesh to do this?

Geoff


Post a reply to this message

From: Jean-Michel Grimaldi
Subject: Re: How to do a fill in
Date: 17 Jan 2001 11:04:29
Message: <3A65C29A.7DBEF76C@via.ecp.fr>
Geoff Wedig wrote:
> 
> I have a set of points on the XY plane which have a clockwise order to form
> a shape.  I want to fill this shape with something.  I can't use a prism
> object for this purpose as it will eventually add a height element.

Then just use a polygon{}.

-- 
JM


Post a reply to this message

From: Geoff Wedig
Subject: Re: How to do a fill in
Date: 17 Jan 2001 13:41:09
Message: <3a65e745@news.povray.org>
Jean-Michel Grimaldi <jm### [at] viaecpfr> wrote:

> Geoff Wedig wrote:
>> 
>> I have a set of points on the XY plane which have a clockwise order to form
>> a shape.  I want to fill this shape with something.  I can't use a prism
>> object for this purpose as it will eventually add a height element.

> Then just use a polygon{}.

No planar form will work, since the height component will get added later.     
I am attempting to project a 2D shape onto a 3D shape.  I was working with     
differences, but that didn't work, so I was trying to generate a mesh to do    
it.  Since the base shape is 2D, I should be able (perhaps by breaking it      
down further) to generate a mesh for the shape.  If I cannot, I can't hope     
to do so in 3D.                                                                
                                                                               
Geoff


Post a reply to this message

From: Ron Parker
Subject: Re: How to do a fill in
Date: 17 Jan 2001 13:56:07
Message: <slrn96bqma.f6b.ron.parker@fwi.com>
On 17 Jan 2001 13:41:09 -0500, Geoff Wedig wrote:
>No planar form will work, since the height component will get added later.     

Please explain what you mean by "the height component will get added later."
Are the vertices going to have different heights?  If so, there are lots
of different solutions for the same problem, but none of the easy ones will
look good.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Josh English
Subject: Re: How to do a fill in
Date: 17 Jan 2001 16:44:47
Message: <3A6612A3.AE801980@spiritone.com>
Choose a point in the center of the object and create a mesh of triangles,
taking two points and connecting them with the center.
You may create internal "rings" depeding on how your xy points are set up, then
you can add the height.

So if your points are in an array of position vectors

#decalre points = array[5]
 { <1,0,0> <1,0,1> <0,0,1> <-1,0,0> <0,0,-1> }
mesh{
#declare cnt = 1;
#while ( cnt < dimension_size(points,1) )
  triangle { <0,0,0> points[cnt] points [cnt-1] }
  #declare cnt = cnt + 1;
#end
texture definition
} // end mesh

That should get you started, then you can start to play with height values. If
you want to smooth them out, take a look at
http://www.spiritone.com/~english/cyclopedia/smooth2.html

Josh

Geoff Wedig wrote:

> I have a set of points on the XY plane which have a clockwise order to form
> a shape.  I want to fill this shape with something.  I can't use a prism
> object for this purpose as it will eventually add a height element.  Does
> anyone know how to generate a mesh to do this?
>
> Geoff

--
Josh English -- Lexiphanic Lethomaniac
eng### [at] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

From: Ron Parker
Subject: Re: How to do a fill in
Date: 17 Jan 2001 16:49:42
Message: <slrn96c4rp.fap.ron.parker@fwi.com>
On Wed, 17 Jan 2001 13:46:11 -0800, Josh English wrote:
>Choose a point in the center of the object and create a mesh of triangles,
>taking two points and connecting them with the center.

This doesn't work in the general case.  It'll work with convex polygons,
and some nonconvex polygons, but it's trivial to construct a polygon it
doesn't work with.


-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Francois Labreque
Subject: Re: How to do a fill in
Date: 17 Jan 2001 19:09:51
Message: <3A6633C2.16DA40EB@videotron.ca>
Geoff Wedig wrote:
> 
> I have a set of points on the XY plane which have a clockwise order to form
> a shape.  I want to fill this shape with something.  I can't use a prism
> object for this purpose as it will eventually add a height element.  Does
> anyone know how to generate a mesh to do this?

Method 1:  (The fan)
- You have a set of n points.  Let's call them p1, p2, ... pn
- Make a triangle with {p1, p2, p3}
- Make a triangle with {p1, p3, p4}
- Repeat until you  {p1, pn-1, pn}

Method 2: (The potato-chip)
- You have a set of n points.  Let's call them p1, p2, ... pn
- Find the average of your points .  This is the center of your shape. 
Let's call it C
- Make a triangle with {C, p1, p2 }
- Make a triangle with {C, p2, p3 }
- repeat until you hit {C, pn-1, pn }
- Make a last triangle with { C, pn, p1}

This works with 2D as well as 3D points.

This shouldn't be too hard to script or program.
-- 
Francois Labreque | In the future, performance will be measured
    flabreque     | by the size of your pipe.
        @         |             - Dogbert, on networking
   videotron.ca


Post a reply to this message

From: Geoff Wedig
Subject: Re: How to do a fill in
Date: 18 Jan 2001 08:09:35
Message: <3a66eb0f$1@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:

> On 17 Jan 2001 13:41:09 -0500, Geoff Wedig wrote:
>>No planar form will work, since the height component will get added later.     

> Please explain what you mean by "the height component will get added later."
> Are the vertices going to have different heights?  If so, there are lots
> of different solutions for the same problem, but none of the easy ones will
> look good.

Ok, let me see if I can explain.  I have a general surface that is never
perpendicular to the z plane  (ie, there are no caves or cliffs).  I
take a set of 2D coordinants <x,y> that I want to raise the surface from  In this
case, raising is defined as moving outwards according to the normal at the
surface at the points <x,y,z(x,y)> where z(x,y) is the height of the surface
at <x,y>.  The set of <X,y> elements have been chosen so that there is not a
great deal of curvature between pairs of x,y elements.  In general, the z
surface is well behaved in this fashion.

Now, I want to create a companion surface above the general surface, with
points <x', y', z'> = <x,y,z(x,y)> + d * N(<x,y,z(x,y)>) where d is some
distance and N(p) is the normal of the surface at point p.

I've tried a variety of methods to do this, and if there is another one, I'd
be interested, but the mesh tesselation approach seems the most promising. 
In this case, I have the outer ring of points and must make a surface based
on it.  What Might be required is a more detailed tesselation, so that
surface details are not lost.

However, even assuming that the surface is totally flat, it is not obvious
how to fill the hole with an accurate mesh without resorting to polygon or
some other primitive that won't work in the 3D case.

What I am now considering is doing a circular reduction.  Ie, for each point,
there is an inside and an outside.  There is also a direction of the inside,
defined by the angle at the point.  So, given some small distance, we can
calculate two points that are offset from the main point that are guaranteed
to be inside the surface.  We can place two triangles between the two
original points and there inside points.  Do this all the way around the
object.  Repeat for the reduced object.  When the line segments from point
to inside point cross, average the insides and do a single triangle instead.

The above should work for anything, assuming the distance is small enough. 
But it would generate a large mesh, which may be unnecessary if the 3D
object is close to flat.  One possibility is determining where the inside
direction lines cross, and checking the normal at that point.  If it doesn't
vary much from the normals at the two original points, create a single
triangle and short circuit this whole mess.  But this is getting very
complex for something that should be mostly simple.

So, anyone got any bright ideas?

Geoff


Post a reply to this message

From: Josh English
Subject: Re: How to do a fill in
Date: 18 Jan 2001 08:50:17
Message: <3A66F4F2.3CBB8E63@spiritone.com>
I'm aware of the limitations (I just didnt' post them, oops) but from what I
understood, it would work for his issue. He didn't go into enough detail, I
guess.

Josh

Ron Parker wrote:

> On Wed, 17 Jan 2001 13:46:11 -0800, Josh English wrote:
> >Choose a point in the center of the object and create a mesh of triangles,
> >taking two points and connecting them with the center.
>
> This doesn't work in the general case.  It'll work with convex polygons,
> and some nonconvex polygons, but it's trivial to construct a polygon it
> doesn't work with.
>
> --
> Ron Parker   http://www2.fwi.com/~parkerr/traces.html
> My opinions.  Mine.  Not anyone else's.

--
Josh English -- Lexiphanic Lethomaniac
eng### [at] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.