POV-Ray : Newsgroups : povray.general : Please Help Me Find My Stupid Mistake Server Time
16 Nov 2024 01:18:39 EST (-0500)
  Please Help Me Find My Stupid Mistake (Message 1 to 4 of 4)  
From: Dave Matthews
Subject: Please Help Me Find My Stupid Mistake
Date: 6 May 2004 14:19:05
Message: <409a8199@news.povray.org>
The code below works, but by my reasoning it shouldn't.  I had to move a 
"}" to what is "clearly" the "wrong" location (obviously it isn't wrong, 
since it works; what is wrong is my logic.)  When I close out my objects 
the way I think I should, I get a parse error.  Can someone spot my 
mistake?

(If the code seems a bit strange, it's because I've stripped it down as 
  much as I can, I think, and still have the problem.)

////////Code
//Ball-And-Stick Fragment

#macro B_And_S_Triangle(V_Array,BR,SR)
         union {
         sphere { 0, 1  scale BR pigment { color rgb x }
                  translate V_Array[0]}
         sphere { 0, 1  scale BR pigment { color rgb y }
                  translate V_Array[1]}
         sphere { 0, 1  scale BR pigment { color rgb z }
                  translate V_Array[2]}
         cylinder { V_Array[0], V_Array[1], SR
                    pigment { color rgb x+y } }
         cylinder { V_Array[0], V_Array[2], SR
                    pigment { color rgb x+y } }
         cylinder { V_Array[1], V_Array[2], SR
                    pigment { color rgb x+y } }
         }
#end
//Of Macro The problem's probably somewhere above, but I can't find it.



// Second macro, calls above macro twice:

#macro Ball_And_Stick(SArray,DArray,B_Rad,S_Rad)

#declare Source_Triangle =
                      B_And_S_Triangle(SArray,B_Rad,S_Rad)

#declare Destination_Triangle =
                      B_And_S_Triangle(DArray,B_Rad/2,S_Rad/2)

//Here's "misplaced" "}"

object { Source_Triangle }}

//I think there should only be one "}" ending above object

object { Destination_Triangle }

#end    //Of 2nd macro


// Here's the main body


#declare Source_Points = array[3];

#declare Source_Points[0] = <0, 0, 0>;
#declare Source_Points[1] = <0, 5, 0>;
#declare Source_Points[2] = <5, 0, 0>;


#declare Destination_Points = array[3];

#declare Destination_Points[0] = <1, 1, 0>;
#declare Destination_Points[1] = <2, 1, 0>;
#declare Destination_Points[2] = <1, 2, 0>;

//Here's "missing" "}"
object { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1)
//I think there should be a "}" to end the above object.

camera { angle 60 location <3, 3, -20>
	look_at <3, 3, 0>
	right x*image_width/image_height
         up y }

light_source { -100*z color rgb 1 }

background { color rgb 0.7 }


//////////////////////////
I've been tearing out what little hair I have left, trying to solve 
this.  Thanks in advance for any help.

Dave Matthews


Post a reply to this message

From: Dave Matthews
Subject: Re: Please Help Me Find My Stupid Mistake
Date: 6 May 2004 14:58:23
Message: <409a8acf$1@news.povray.org>
Never mind.  I found it.  I need a "union" in my second macro to make it 
work the way I thought it should -- i.e. treat it as a single object.

Dave Matthews

Dave Matthews wrote:
> The code below works, but by my reasoning it shouldn't.  I had to move a 
> "}" to what is "clearly" the "wrong" location (obviously it isn't wrong, 
> since it works; what is wrong is my logic.)  When I close out my objects 
> the way I think I should, I get a parse error.  Can someone spot my 
> mistake?
> 
> (If the code seems a bit strange, it's because I've stripped it down as 
>  much as I can, I think, and still have the problem.)
> 
> ////////Code
> //Ball-And-Stick Fragment
> 
> #macro B_And_S_Triangle(V_Array,BR,SR)
>         union {
>         sphere { 0, 1  scale BR pigment { color rgb x }
>                  translate V_Array[0]}
>         sphere { 0, 1  scale BR pigment { color rgb y }
>                  translate V_Array[1]}
>         sphere { 0, 1  scale BR pigment { color rgb z }
>                  translate V_Array[2]}
>         cylinder { V_Array[0], V_Array[1], SR
>                    pigment { color rgb x+y } }
>         cylinder { V_Array[0], V_Array[2], SR
>                    pigment { color rgb x+y } }
>         cylinder { V_Array[1], V_Array[2], SR
>                    pigment { color rgb x+y } }
>         }
> #end
> //Of Macro The problem's probably somewhere above, but I can't find it.
> 
> 
> 
> // Second macro, calls above macro twice:
> 
> #macro Ball_And_Stick(SArray,DArray,B_Rad,S_Rad)
> 
> #declare Source_Triangle =
>                      B_And_S_Triangle(SArray,B_Rad,S_Rad)
> 
> #declare Destination_Triangle =
>                      B_And_S_Triangle(DArray,B_Rad/2,S_Rad/2)
> 
> //Here's "misplaced" "}"
> 
> object { Source_Triangle }}
> 
> //I think there should only be one "}" ending above object
> 
> object { Destination_Triangle }
> 
> #end    //Of 2nd macro
> 
> 
> // Here's the main body
> 
> 
> #declare Source_Points = array[3];
> 
> #declare Source_Points[0] = <0, 0, 0>;
> #declare Source_Points[1] = <0, 5, 0>;
> #declare Source_Points[2] = <5, 0, 0>;
> 
> 
> #declare Destination_Points = array[3];
> 
> #declare Destination_Points[0] = <1, 1, 0>;
> #declare Destination_Points[1] = <2, 1, 0>;
> #declare Destination_Points[2] = <1, 2, 0>;
> 
> //Here's "missing" "}"
> object { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1)
> //I think there should be a "}" to end the above object.
> 
> camera { angle 60 location <3, 3, -20>
>     look_at <3, 3, 0>
>     right x*image_width/image_height
>         up y }
> 
> light_source { -100*z color rgb 1 }
> 
> background { color rgb 0.7 }
> 
> 
> //////////////////////////
> I've been tearing out what little hair I have left, trying to solve 
> this.  Thanks in advance for any help.
> 
> Dave Matthews
>


Post a reply to this message

From: Mike Williams
Subject: Re: Please Help Me Find My Stupid Mistake
Date: 6 May 2004 15:25:40
Message: <$P1zNDAyDpmAFw8J@econym.demon.co.uk>
Wasn't it Dave Matthews who wrote:
>The code below works, but by my reasoning it shouldn't.  I had to move a 
>"}" to what is "clearly" the "wrong" location (obviously it isn't wrong, 
>since it works; what is wrong is my logic.)  When I close out my objects 
>the way I think I should, I get a parse error.  Can someone spot my 
>mistake?


The problem is that the Ball_And_Stick() macro doesn't return an object,
it returns two objects. So you can't say

  object { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1) }


You can fix it by saying

  union { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1) }


or by making Ball_And_Stick() return a single union of the two objects

  union {
    object { Source_Triangle }
    object { Destination_Triangle }
  }
  ...
  object { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1) }


The error message isn't very helpful, but I guess that the POV parser
got just as confused as you did.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Dave Matthews
Subject: Re: Please Help Me Find My Stupid Mistake
Date: 7 May 2004 11:11:04
Message: <409ba708$1@news.povray.org>
Mike Williams wrote:

> The problem is that the Ball_And_Stick() macro doesn't return an object,
> it returns two objects. So you can't say
> 
>   object { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1) }
> 
> 
> You can fix it by saying
> 
>   union { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1) }
> 
> 
> or by making Ball_And_Stick() return a single union of the two objects
> 
>   union {
>     object { Source_Triangle }
>     object { Destination_Triangle }
>   }
>   ...
>   object { Ball_And_Stick(Source_Points,Destination_Points,0.5, 0.1) }
> 
> 
> The error message isn't very helpful, but I guess that the POV parser
> got just as confused as you did.
> 

Thanks, Mike.

As you can see, above, I finally found it also.  Actually what made it 
dawn on me, was trying to translate the whole thing.  Only the first 
part moved, then I realized that I had two objects.

Dave Matthews


Post a reply to this message

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