POV-Ray : Newsgroups : povray.general : Suggestion for new object Server Time
16 Nov 2024 15:16:19 EST (-0500)
  Suggestion for new object (Message 1 to 10 of 22)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Mikael Gustafsson
Subject: Suggestion for new object
Date: 5 Jul 1998 22:56:14
Message: <35a02ebe.0@news.povray.org>
Sorry for a second post but the last sentence was a bit confusing.

With POV-Ray 3.1 I think it would be possible to incorporate a new object.
Well, here's my two cents on the subject. The current box is probably one of
the most used objects in POV, but it has some drawbacks. The current syntax
only allows boxes with 90 degree corners. But if POV inwoked a new object
that lets the user define all eight corners of the box, it would among other
things help creating #while loops that have flat areas as complex matrix
transformations that are required with the current boxes coule be avoided.

Mikael Gustafsson
mik### [at] nettifi


Post a reply to this message

From: Dan Connelly
Subject: Re: Suggestion for new object
Date: 6 Jul 1998 01:18:22
Message: <35A04FFC.DD7838CE@flash.net>
This is pretty trivial with #macro, union, and polygon.

for example (not debugged)

#macro metabox(P0, P1, P2, P3, P4, P5, P6, P7)
  union {
    polygon {5, P0, P1, P2, P3, P0}
    polygon {5, P4, P5, P6, P7, P4}
    polygon {5, P0, P1, P5, P4, P0}
    polygon {5, P1, P2, P6, P5, P1}
    polygon {5, P2, P3, P7, P6, P3}
    polygon {5, P3, P0, P4, P7, P3}
  }
#end


Mikael Gustafsson wrote:
> 
> Sorry for a second post but the last sentence was a bit confusing.
> 
> With POV-Ray 3.1 I think it would be possible to incorporate a new object.
> Well, here's my two cents on the subject. The current box is probably one of
> the most used objects in POV, but it has some drawbacks. The current syntax
> only allows boxes with 90 degree corners. But if POV inwoked a new object
> that lets the user define all eight corners of the box, it would among other
> things help creating #while loops that have flat areas as complex matrix
> transformations that are required with the current boxes coule be avoided.
> 
> Mikael Gustafsson
> mik### [at] nettifi

-- 
http://www.flash.net/~djconnel/


Post a reply to this message

From: PoD
Subject: Re: Suggestion for new object
Date: 6 Jul 1998 17:08:28
Message: <35A12EB5.7BF2@merlin.net.au>
Dan Connelly wrote:
> 
> This is pretty trivial with #macro, union, and polygon.
> 
> for example (not debugged)
> 
> #macro metabox(P0, P1, P2, P3, P4, P5, P6, P7)
>   union {
>     polygon {5, P0, P1, P2, P3, P0}
>     polygon {5, P4, P5, P6, P7, P4}
>     polygon {5, P0, P1, P5, P4, P0}
>     polygon {5, P1, P2, P6, P5, P1}
>     polygon {5, P2, P3, P7, P6, P3}
>     polygon {5, P3, P0, P4, P7, P3}
>   }
> #end
> 
> Mikael Gustafsson wrote:
> >
> > Sorry for a second post but the last sentence was a bit confusing.
> >
> > With POV-Ray 3.1 I think it would be possible to incorporate a new object.
> > Well, here's my two cents on the subject. The current box is probably one of
> > the most used objects in POV, but it has some drawbacks. The current syntax
> > only allows boxes with 90 degree corners. But if POV inwoked a new object
> > that lets the user define all eight corners of the box, it would among other
> > things help creating #while loops that have flat areas as complex matrix
> > transformations that are required with the current boxes coule be avoided.
> >
> > Mikael Gustafsson
> > mik### [at] nettifi
> 
> --
> http://www.flash.net/~djconnel/

But that can't be CSGd.


Post a reply to this message

From: Guy Rauscher
Subject: Re: Suggestion for new object
Date: 6 Jul 1998 19:06:53
Message: <35A1E46B.66EA@netvision.net.il>
PoD wrote:
> 
> Dan Connelly wrote:
> >
> > This is pretty trivial with #macro, union, and polygon.
> >
> > for example (not debugged)
> >
> > #macro metabox(P0, P1, P2, P3, P4, P5, P6, P7)
> >   union {
> >     polygon {5, P0, P1, P2, P3, P0}
> >     polygon {5, P4, P5, P6, P7, P4}
> >     polygon {5, P0, P1, P5, P4, P0}
> >     polygon {5, P1, P2, P6, P5, P1}
> >     polygon {5, P2, P3, P7, P6, P3}
> >     polygon {5, P3, P0, P4, P7, P3}
> >   }
> > #end
> >
> > Mikael Gustafsson wrote:
> > >
> > > Sorry for a second post but the last sentence was a bit confusing.
> > >
> > > With POV-Ray 3.1 I think it would be possible to incorporate a new object.
> > > Well, here's my two cents on the subject. The current box is probably one of
> > > the most used objects in POV, but it has some drawbacks. The current syntax
> > > only allows boxes with 90 degree corners. But if POV inwoked a new object
> > > that lets the user define all eight corners of the box, it would among other
> > > things help creating #while loops that have flat areas as complex matrix
> > > transformations that are required with the current boxes coule be avoided.
> > >
> > > Mikael Gustafsson
> > > mik### [at] nettifi
> >
> > --
> > http://www.flash.net/~djconnel/
> 
> But that can't be CSGd.

You could create the object with an intersection of planes. Then in
could be CSGd.

Guy


Post a reply to this message

From: Mikael Gustafsson
Subject: Re: Suggestion for new object
Date: 6 Jul 1998 21:19:29
Message: <35a16991.0@news.povray.org>
One could also use  matrix-shearing, but I still think a new object of the
kind described earlier would be cool and at least somewhat useful.

Guy Rauscher wrote in message <35A### [at] netvisionnetil>...
>PoD wrote:
>>
>>
>> But that can't be CSGd.
>
>You could create the object with an intersection of planes. Then in
>could be CSGd.
>
>Guy


Post a reply to this message

From: Dan Connelly
Subject: Re: Suggestion for new object
Date: 6 Jul 1998 22:28:34
Message: <35A179AE.62A93251@flash.net>
PoD wrote:
> 
> Dan Connelly wrote:
> >
> > This is pretty trivial with #macro, union, and polygon.
> >
> > for example (not debugged)
> >
> > #macro metabox(P0, P1, P2, P3, P4, P5, P6, P7)
> >   union {
> >     polygon {5, P0, P1, P2, P3, P0}
> >     polygon {5, P4, P5, P6, P7, P4}
> >     polygon {5, P0, P1, P5, P4, P0}
> >     polygon {5, P1, P2, P6, P5, P1}
> >     polygon {5, P2, P3, P7, P6, P3}
> >     polygon {5, P3, P0, P4, P7, P3}
> >   }
> > #end
> 
> But that can't be CSGd.

You are absolutely correct : soon after firing off my reply in
my usual reckless fashion, I realized I was proposing a shell
and not a solid object... like Bezier patch objects.

Unfortunately, the solid object is harder to define.  First of
all, if the faces are planar, the vertices overspecify the problem,
as there is no guarantee that a plane can be defined which
intersects a given set of four points in 3-d space.

I believe the way to specify the object would need to be via
other parameters.  An example would be 6 normal vectors 
from the origin to the planes... 6 points instead of 8.

Alternatively, the object can be specified in terms of 6
of the 8 vertices, such that each face has exactly 3 points
specified (each point shared by 3 planes).

The implementation becomes the intersection of 6 planes, with some
care taken to avoid "sign errors" in the CSG (if the normal
specification is used)... if the object
is constrained to include the origin, this is easy, otherwise
there is some bookkeeping to be done.


Dan


-- 
http://www.flash.net/~djconnel/


Post a reply to this message

From: Nieminen Mika
Subject: Re: Suggestion for new object
Date: 7 Jul 1998 18:46:52
Message: <35a2974c.0@news.povray.org>
Mikael Gustafsson <mik### [at] nettifi> wrote:
: But if POV inwoked a new object
: that lets the user define all eight corners of the box

  What does this kind of box look like?

metabox
{ <0,0,0>, <1,0,0>, <1,1,0>, <0,1,0>
  <0,0,1>, <1,0,1>, <1,1,1>, <0,1,0.5>
}

-- 
                                                              - Warp. -


Post a reply to this message

From: Chris Colefax
Subject: Re: Suggestion for new object
Date: 11 Jul 1998 11:27:00
Message: <35A758E2.B905443A@geocities.com>
Mikael Gustafsson wrote:
> 
> Sorry for a second post but the last sentence was a bit confusing.
> 
> With POV-Ray 3.1 I think it would be possible to incorporate a new object.
> Well, here's my two cents on the subject. The current box is probably one of
> the most used objects in POV, but it has some drawbacks. The current syntax
> only allows boxes with 90 degree corners. But if POV inwoked a new object
> that lets the user define all eight corners of the box, it would among other
> things help creating #while loops that have flat areas as complex matrix
> transformations that are required with the current boxes coule be avoided.

Perhaps the file below will do what you want; the syntax (after
including the file) is as follows:

   metabox (<Point1>, <Point2>, <Point3>, <Point4>, <Point5>, <Point6>, <Point7>,
<Point8>)

which creates a solid box with the vertices as specified.  Points 1 to
4 should specify one face of the metabox (in either clockwise or anti-
clockwise direction), with points 5 to 8 specifying the opposide side
of the box (specified in the same direction as the first face).

As has been mentioned in other messages, though, it is possible that
the points will specify a box with one or more faces not being flat.  In
this case, the macro will automatically create a metabox with bent faces
to fit all eight vertices.  Alternatively, you can create such metaboxes
directly using the flat_metabox macro:

   flat_metabox (<Point1>, <Point2>, <Point3>, <Point4>, <Point5>, <Point6>, <Point7>,
<Point8>)
   
or, you can create the boxes with smooth faces (that curve to fit the
vertices) using the smooth_metabox macro:

   smooth_metabox (<Point1>, <Point2>, <Point3>, <Point4>, <Point5>, <Point6>,
<Point7>, <Point8>)

Note that, unlike the solid metabox, the flat_metabox and
smooth_metabox cannot be used in CSG operations (although they can be
clipped).  However, they can be used as media containers, eg:

   object {smooth_metabox (
      <-1, -2, -1>, <1, -1, -1>, <1, -2, 1>, <-1, -1, 1>,
      <0, 2, -1>, <1, 1, 0>, <0, 2, 1>, <-1, 1, 0>)
      hollow
      pigment {rgbf 1}
      interior {media {.....}}
      }


// -- Metabox.inc ----------------------------

#macro flat_metabox (FP1, FP2, FP3, FP4, BP1, BP2, BP3, BP4)
   mesh {
      triangle {FP1, FP2, FP3} triangle {FP1, FP3, FP4}  // Front
      triangle {FP1, BP1, BP2} triangle {FP1, BP2, FP2}  // Top
      triangle {FP1, FP4, BP4} triangle {FP1, BP4, BP1}  // Left
      triangle {BP1, BP4, BP3} triangle {BP1, BP3, BP2}  // Back
      triangle {FP4, FP3, BP3} triangle {FP4, BP3, BP4}  // Bottom
      triangle {FP2, BP2, BP3} triangle {FP2, BP3, FP3}  // Right
      }
#end

#macro metabox (FP1, FP2, FP3, FP4, BP1, BP2, BP3, BP4)
   #local _MB_normal1 = -vcross(FP1 - FP2, FP2 - FP3);
   #if (vdot(_MB_normal1, FP4 - FP1) != 0) #local _MB_warning = "point1, point2,
point3, and point4 are not co-planar" #end

   #local _MB_normal2 = -vcross(FP1 - BP1, BP1 - BP2);
   #if (vdot(_MB_normal2, FP2 - FP1) != 0) #local _MB_warning = "point1, point2,
point5, and point6 are not co-planar" #end

   #local _MB_normal3 = -vcross(FP1 - FP4, FP4 - BP4);
   #if (vdot(_MB_normal3, BP1 - FP1) != 0) #local _MB_warning = "point1, point4,
point5, and point8 are not co-planar" #end

   #local _MB_normal4 = -vcross(BP1 - BP4, BP4 - BP3);
   #if (vdot(_MB_normal4, BP2 - BP1) != 0) #local _MB_warning = "point5, point6,
point7, and point8 are not co-planar" #end

   #local _MB_normal5 = -vcross(FP4 - FP3, FP3 - BP3);
   #if (vdot(_MB_normal5, BP4 - FP4) != 0) #local _MB_warning = "point3, point4,
point7, and point8 are not co-planar" #end

   #local _MB_normal6 = -vcross(FP2 - BP2, BP2 - BP3);
   #if (vdot(_MB_normal6, FP3 - FP2) != 0) #local _MB_warning = "point2, point3,
point6, and point7 are not co-planar" #end
   
   #ifdef (_MB_warning)
      #warning concat("metabox: ", _MB_warning, ", flat_metabox created.\r\n")
      flat_metabox (FP1, FP2, FP3, FP4, BP1, BP2, BP3, BP4)

   #else
      #local _MB_axis = ((BP1 + BP2 + BP3 + BP4) / 4) - ((FP1 + FP2 + FP3 + FP4) / 4);
      #if (vlength(_MB_normal1 - _MB_axis) < vlength(-_MB_normal1 - _MB_axis))
         #local _MB_normaldir = -1;
      #else
         #local _MB_normaldir = 1;
      #end

      intersection {
         plane {_MB_normaldir * _MB_normal1, 0 translate FP1}
         plane {_MB_normaldir * _MB_normal2, 0 translate FP1}
         plane {_MB_normaldir * _MB_normal3, 0 translate FP1}
         plane {_MB_normaldir * _MB_normal4, 0 translate BP1}
         plane {_MB_normaldir * _MB_normal5, 0 translate FP4}
         plane {_MB_normaldir * _MB_normal6, 0 translate FP2}
      }
   #end
#end

#macro smooth_metabox (FP1, FP2, FP3, FP4, BP1, BP2, BP3, BP4)
   union {
      #local _MB_face = 0; #while (_MB_face < 6)
         #switch (_MB_face)
            #case (0) #local P1 = FP1 * <1, 1, 1>; #local P2 = FP2 * <1, 1, 1>;
               #local P3 = FP3 * <1, 1, 1>; #local P4 = FP4 * <1, 1, 1>; #break
            #case (1) #local P1 = FP1 * <1, 1, 1>; #local P2 = BP1 * <1, 1, 1>;
               #local P3 = BP2 * <1, 1, 1>; #local P4 = FP2 * <1, 1, 1>; #break
            #case (2) #local P1 = FP1 * <1, 1, 1>; #local P2 = FP4 * <1, 1, 1>;
               #local P3 = BP4 * <1, 1, 1>; #local P4 = BP1 * <1, 1, 1>; #break
            #case (3) #local P1 = BP1 * <1, 1, 1>; #local P2 = BP4 * <1, 1, 1>;
               #local P3 = BP3 * <1, 1, 1>; #local P4 = BP2 * <1, 1, 1>; #break
            #case (4) #local P1 = FP4 * <1, 1, 1>; #local P2 = FP3 * <1, 1, 1>;
               #local P3 = BP3 * <1, 1, 1>; #local P4 = BP4 * <1, 1, 1>; #break
            #case (5) #local P1 = FP2 * <1, 1, 1>; #local P2 = BP2 * <1, 1, 1>;
               #local P3 = BP3 * <1, 1, 1>; #local P4 = FP3 * <1, 1, 1>;
         #end

         #local PA = (P2 - P1) / 3;
         #local PB = (P4 - P1) / 3;
         #local PC = (P3 - P2) / 3;
         #local PD = (P3 - P4) / 3;
         #local PE = (P1 + PB); #local PF = P2 + PC; #local PG = (PF - PE) / 3;
         #local PH = P4 - PB; #local PI = P3 - PC; #local PJ = (PI - PH) / 3;

      bicubic_patch {type 1 u_steps 2 v_steps 2 flatness .01
         P1,  P1+PA,  P2-PA,  P2,
         PE,  PE+PG,  PF-PG,  PF,
         PH,  PH+PJ,  PI-PJ,  PI,
         P4,  P4+PD,  P3-PD,  P3}

      #local _MB_face = _MB_face + 1; #end
      }
#end

// -- End File --------------------------------


Post a reply to this message

From: Dan Connelly
Subject: Re: Suggestion for new object
Date: 11 Jul 1998 16:31:04
Message: <35A7BD69.E25D5B72@flash.net>
Nice post!  

However, the following test may well yield false warnings due to
floating point rounding problems, I suspect.

I more careful approach might be to normalize the dot product
by the magnitude of the cross product, take the magnitude of
the difference, and compare it against a small positive number,
taking care to avoid singularities.


Dan


Chris Colefax wrote:
> 
>    #local _MB_normal1 = -vcross(FP1 - FP2, FP2 - FP3);
>    #if (vdot(_MB_normal1, FP4 - FP1) != 0) #local _MB_warning = "point1, point2,
point3, and point4 are not co-planar" #end

-- 
http://www.flash.net/~djconnel/


Post a reply to this message

From: Mikael Gustafsson
Subject: Re: Suggestion for new object
Date: 11 Jul 1998 19:13:43
Message: <35a7e397.0@news.povray.org>
Wow, thank you very much. Works great judging on a few quick tests.

Mikael Gustafsson
mik### [at] nettifi

Chris Colefax wrote in message <35A758E2.B905443A@geocities.com>...
>
>Perhaps the file below will do what you want; the syntax (after
>including the file) is as follows:
>
>   metabox (<Point1>, <Point2>, <Point3>, <Point4>, <Point5>, <Point6>,
<Point7>, <Point8>)
>
>which creates a solid box with the vertices as specified.  Points 1 to
>4 should specify one face of the metabox (in either clockwise or anti-
>clockwise direction), with points 5 to 8 specifying the opposide side
>of the box (specified in the same direction as the first face).


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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