 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
OK, have a look at this:
#macro Rectangle(A, B, C, D, r)
sphere {A, r}
sphere {B, r}
sphere {C, r}
sphere {D, r}
cylinder {A, B, r}
cylinder {B, C, r}
cylinder {C, D, r}
cylinder {D, A, r}
#end
As you can see, this draws a wireframe rectangle between 4
user-specified points in space.
Assuming that all 4 points are actually co-plannar, what would the *the
simplest* way to fit a box{} object into the middle of the thing?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v2 <voi### [at] dev null> wrote:
> Assuming that all 4 points are actually co-plannar, what would the *the
> simplest* way to fit a box{} object into the middle of the thing?
Actually it's not enough for the points to be coplanar, they must also
form a perfect parallelogram or else 1 box will not do. If the shape is
not a perfect parallelogram then you'll have to use at least the difference
of two or three boxes.
Of course you could go the easy way and close that object with
polygons or even triangles, unless you really want it to be solid,
in which case you'll have to either go with the boxes or use eg.
planes.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>Assuming that all 4 points are actually co-plannar, what would the *the
>>simplest* way to fit a box{} object into the middle of the thing?
>
>
> Actually it's not enough for the points to be coplanar, they must also
> form a perfect parallelogram or else 1 box will not do. If the shape is
> not a perfect parallelogram then you'll have to use at least the difference
> of two or three boxes.
>
> Of course you could go the easy way and close that object with
> polygons or even triangles, unless you really want it to be solid,
> in which case you'll have to either go with the boxes or use eg.
> planes.
Used for CSG --> I'd like it to be solid.
Hmm... planes is a good idea though!
(Actually, the code that generates the 4 points guarantees them to form
a rectangle. To be specific, A and B are identical except for the Z
coordinate, as are C and D...)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v2 wrote:
> OK, have a look at this:
>
> #macro Rectangle(A, B, C, D, r)
> sphere {A, r}
> sphere {B, r}
> sphere {C, r}
> sphere {D, r}
> cylinder {A, B, r}
> cylinder {B, C, r}
> cylinder {C, D, r}
> cylinder {D, A, r}
> #end
>
> As you can see, this draws a wireframe rectangle between 4
> user-specified points in space.
>
> Assuming that all 4 points are actually co-plannar, what would the *the
> simplest* way to fit a box{} object into the middle of the thing?
Use Matrix_Trans() or Shear_Trans()
(These are macros in transforms.inc)
This may also be relevant:
"How to transform a triangle into another", 2. October 2002
http://news.povray.org/povray.text.tutorials/thread/%3C3D9B843D.E5392CD0@hotmail.com%3E
http://tinyurl.com/nwvck
--
Tor Olav
http://subcube.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v2 <voi### [at] dev null> wrote:
> (Actually, the code that generates the 4 points guarantees them to form
> a rectangle. To be specific, A and B are identical except for the Z
> coordinate, as are C and D...)
I don't think that's a guarantee of rectangularity nor even
parallelogramity.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tor Olav Kristensen <tor### [at] toberemovedgmail com> wrote:
> > Assuming that all 4 points are actually co-plannar, what would the *the
> > simplest* way to fit a box{} object into the middle of the thing?
> Use Matrix_Trans() or Shear_Trans()
That will only work if the points form a perfect parallelogram.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Tor Olav Kristensen <tor### [at] toberemovedgmail com> wrote:
>>> Assuming that all 4 points are actually co-plannar, what would the *the
>>> simplest* way to fit a box{} object into the middle of the thing?
>
>> Use Matrix_Trans() or Shear_Trans()
>
> That will only work if the points form a perfect parallelogram.
Yes, that's true.
(But I assumed that he wanted to use his macro for his wireframe
letters. See his latest post in povray.binaries.images)
--
Tor Olav
http://subcube.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>(Actually, the code that generates the 4 points guarantees them to form
>>a rectangle. To be specific, A and B are identical except for the Z
>>coordinate, as are C and D...)
>
>
> I don't think that's a guarantee of rectangularity nor even
> parallelogramity.
Why not?
Oh, did I not mention that A and C have *the same* Z coordinate? (As do
B and D...)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Use Matrix_Trans() or Shear_Trans()
> (These are macros in transforms.inc)
Thanks for the tip! :-D
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
This seems to work...
#macro DrawPoly(Points, Radius)
#local A = Points[0];
#local B = Points[1];
#local C = Points[2];
#local AB = B - A;
#local AC = C - A;
#local Norm = vnormalize(vcross(AB, AC));
#local V1 = Norm;
#local V2 = vnormalize(AB);
#local V3 = vcross(V1, V2);
prism
{
linear_sweep
linear_spline
-Radius, +Radius, dimension_size(Points, 1),
#local lp = 0;
#while (lp < dimension_size(Points, 1))
<vdot(V3, Points[lp]), vdot(V2, Points[lp])>
#local lp = lp + 1;
#end
translate +y*vdot(A, Norm)
Reorient_Trans(y, Norm)
}
#end
In case it way be of use to anybod else...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v2 wrote:
> This seems to work...
>
> In case it way be of use to anybod else...
Could you provide an example of use? I can't get it to work in the test
scene below. Granted, it doesn't use a parallelogram, but it looks like it
is meant to handle other coplanar points too. Besides, doesn't work with a
parallelogram either. If you really need it for parallelograms only, then I
can think of a simpler solution that uses a box instead of a prism.
#include "transforms.inc"
#macro Rectangle(A, B, C, D, r)
sphere {A, r}
sphere {B, r}
sphere {C, r}
sphere {D, r}
cylinder {A, B, r}
cylinder {B, C, r}
cylinder {C, D, r}
cylinder {D, A, r}
#end
#macro DrawPoly(Points, Radius)
#local A = Points[0];
#local B = Points[1];
#local C = Points[2];
#local AB = B - A;
#local AC = C - A;
#local Norm = vnormalize(vcross(AB, AC));
#local V1 = Norm;
#local V2 = vnormalize(AB);
#local V3 = vcross(V1, V2);
prism
{
linear_sweep
linear_spline
-Radius, +Radius, dimension_size(Points, 1),
#local lp = 0;
#while (lp < dimension_size(Points, 1))
<vdot(V3, Points[lp]), vdot(V2, Points[lp])>
#local lp = lp + 1;
#end
translate +y*vdot(A, Norm)
Reorient_Trans(y, Norm)
}
#end
#declare Points = array[4] {<-1,-1,0>, <1,-2,1>, <1,2,1>, <-1,2,0>}
camera {location -6*z}
light_source {<-1,2,-3>*1000, color rgb 1}
union {
Rectangle(Points[0],Points[1],Points[2],Points[3], 0.3)
DrawPoly(Points, 0.3)
pigment {rgb 1}
}
Rune
--
http://runevision.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>This seems to work...
>>
>>In case it way be of use to anybod else...
>
>
> Could you provide an example of use? I can't get it to work in the test
> scene below. Granted, it doesn't use a parallelogram, but it looks like it
> is meant to handle other coplanar points too. Besides, doesn't work with a
> parallelogram either. If you really need it for parallelograms only, then I
> can think of a simpler solution that uses a box instead of a prism.
It *is* supposed to work for any polygone. Apparently it doesn't...
Please rip out the line at the end of DrawPoly() that says
Reorient_Trans(y, Norm)
and replace it with
Shear_Trans(V3, V1, V2)
Let me know if that fixes the problem...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid XP v2 wrote:
> It *is* supposed to work for any polygone. Apparently it doesn't...
>
> Please rip out the line at the end of DrawPoly() that says
>
> Reorient_Trans(y, Norm)
>
> and replace it with
>
> Shear_Trans(V3, V1, V2)
>
> Let me know if that fixes the problem...
It seems to fix it. :)
Rune
--
http://runevision.com
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>Let me know if that fixes the problem...
>
>
> It seems to fix it. :)
Introduces an extra rotation that just happens not to be necessary in
the special case I had when I designed the thing. ;-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |