POV-Ray : Newsgroups : povray.programming : Twisted Squares : Re: Twisted Squares Server Time
28 Jul 2024 14:21:04 EDT (-0400)
  Re: Twisted Squares  
From: John VanSickle
Date: 18 Oct 2000 08:34:15
Message: <39ED98C7.A0AC8C6@erols.com>
Edmund Horner wrote:
> 
> Why thank you both _indeed_ for your quick replies.  It is
> _gratifying_ to be told that I'm posting in the wrong group.
> 
> Unfortunately however my question does relate to the povray source.
> 
> The object I want to render has is mathematically reasonable, just as
> any other povray primiative is.  And povray does not appear to support
> it.  I _need_ to create a new primitive.

Only if you want the normals to be smoothed (which would be helpful).

> Given four points in space, A,B,C, and D, with line segments AB, and CD.
> The surface is the set of all lines from each point on AB to its
> corresponding point on CD.  (Corresponding means of the same ratio from the
> ends of its line.)
> 
> I am assured that this is mathemetically well-defined.

It is, and it is called the saddle.  It is described by the equation xy-z=0.
Your specifics call for clipping the surface to the region -1<=x<=1
intersected with -1<=y<=1.  You can also call it a bilinear Bezier patch.

The following macro will draw this object.

#macro Saddle(pA,pB,pC,pD)

#local vX=(pA-pB-pC+pD)/4;
#local vY=(pA+pB-pC-pD)/4;
#local vZ=(pA-pB+pC-pD)/4;
#local vM=(pA+pB+pC+pD)/4;

quadric { <0,0,0>,<1,0,0>,<0,0,-1>,0
  hollow
  clipped_by { box { -1,1 } }
  bounded_by { clipped_by }
  matrix < vX.x,vX.y,vX.z, vY.x,vY.y,vY.z, 
           vZ.x,vZ.y,vZ.z,vM.x,vM.y,vM.z >
}
#end

It would be used this way:

union {
  Saddle(PointA,PointB,PointC,PointD)
  Saddle(PointD,PointC,PointE,PointF) // note change in order of C and D
  // etc
  texture { MyTexture }
}

If you try this, you will note that the surfaces of these patches are
not necessarily continuous at the edges; to eliminate the sudden changes
in shading that will result, normal interpolation is needed; you can
either simulate the patch with four smoothed triangles, or create a
new primitive.

If you want to make a new primitive, you can always download the POV
source, figure out how it works, add the code that will accomplish what
you want, and re-compile it.  Several people have done this.

Regards,
John


Post a reply to this message

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