POV-Ray : Newsgroups : povray.newusers : parse error end of file but #end expected, is my code correct? Server Time: 14 Dec 2018 14:15:07 GMT
  parse error end of file but #end expected, is my code correct? (Message 1 to 4 of 4)  
From: daisy807
Subject: parse error end of file but #end expected, is my code correct?
Date: 4 Dec 2017 01:50:00
Message: <web.5a24a9807a067c974df778040@news.povray.org>
global_settings { ambient_light 4 }
//
#include "colors.inc"
#include "shapes.inc"
#include "math.inc"

#macro round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT)

//Joining lines
//
#local EdgeRadius = 1;

union{
   object{Round_Cone2(p3, r3, p1, r1, EdgeRadius)texture{rT}   }
   object{Round_Cone2(p1, r1, p2, r2, EdgeRadius)texture{bT}   }
   object{Round_Cone2(p2, r2, p3, r3, EdgeRadius)texture{gT}   }

#end
//
//Triangle definitions
//
#declare p1 = <-5,0,0>;
#declare p2 = <5,4,0>;
#declare p3 = <-5,9,0>;
#declare r1 = 5;
#declare r2 = 3;
#declare r3 = 1;

//Colour Textures
#declare bT   = texture{ pigment {  rgb<0,0,1> } }     //Blue
#declare rT   = texture{ pigment {  rgb<1,0,0> } }     //Red
#declare gT   = texture{ pigment {  rgb<0,1,0> } }     //Green
#declare vT   = texture{ pigment {  rgb<0.5,0,1> }}    //Violet

object{round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT) }
//

#macro
SF_roundtriangleintpoints(Point1,Point2,iNorm,vertA,vertB,vertC,radA,radB,radC)
//
#local vertA = <-5,0,0>;
#local vertB = <5,4,0>;
#local vertC = <-5,9,0>;
#local radA = 5;
#local radB = 3;
#local radC = 1;
//
#if(radA<=0)
  #local iNorm  = 0;
  #local Point1 = vertA;
  #local Point2 = vertA;
#else
  #local AtoB       = vertB - vertA;
  #local ellAB      = vlength(AtoB);
  #if(ellAB>abs(radA-radB))
// May not degenerate to a single roundcone
    #local AtoB       = AtoB/ellAB;
    #local cyl1AB     = vertA + radA*(radA - radB)*AtoB/ellAB;
    #local sinalphaAB = (radA - radB)/ellAB;
// Given the #if condition, 0 < sinalphaAB < 1
    #local cosalphaAB = sqrt(1-sinalphaAB*sinalphaAB);
    #local AtoC       = vertC - vertA;
    #local ellAC      = vlength(AtoC);
    #if(ellAC>abs(radA-radC))
// May not degenerate to a single roundcone
      #local AtoC       = AtoC/ellAC;
      #local cyl1AC     = vertA + radA*(radA - radA)*AtoC/ellAC;
      #local cyl2AC     = vertC + radC*(radA - radC)*AtoC/ellAC;
      #local sinalphaAC = (radA - radC)/ellAC;
// Given the #if condition, 0 < sinalphAC < 1
      #local cosalphaAC = sqrt(1-sinalphaAC*sinalphaAC);
      #local cosbetaABC = vdot(AtoB,AtoC);
      #if(cosbetaABC > 1)
        #local cosbetaABC = 1;
      #end
      #local sinbetaABC = sqrt(1 - cosbetaABC*cosbetaABC);
      #local AtoBperpC  = AtoC - cosbetaABC*AtoB;
      #local lAtoBperpC = vlength(AtoBperpC);
      #if(lAtoBperpC > 0)
        #local AtoBperpC  = AtoBperpC/vlength(AtoBperpC);
      #end
      #local ABCperp    = vcross(AtoB,AtoC);
      #local ABCArea    = vlength(ABCperp);
      #if(ABCArea > 0)
        #local ABCperp    = ABCperp/ABCArea;
        #local yABC       =
radA*((radA-radC)/ellAC-cosbetaABC*(radA-radB)/ellAB)/sinbetaABC;
        #local zABC       = radA*radA - yABC*yABC -
(radA*(radA-radB)/ellAB)*(radA*(radA-radB)/ellAB);
      #else
        #local zABC       = -1;
      #end
      #if(zABC>=0.000000001)
// Didn't degenerate into a single roundcone
        #local zABC   = sqrt(zABC);
        #local iNorm  = 1;
        #local Point1 = cyl1AB + yABC*AtoBperpC + zABC*ABCperp;
        #local Point2 = cyl1AB + yABC*AtoBperpC - zABC*ABCperp;
      #else
        #local iNorm  = -1;
        #local Point1 = vertA;
        #local Point2 = vertA;
      #end
    #else
      #local iNorm  = -1;
      #local Point1 = vertA;
      #local Point2 = vertA;
    #end
  #else
    #local iNorm  = -1;
    #local Point1 = vertA;
    #local Point2 = vertA;
  #end
#end
//

//
object{SF_roundtriangleintpoints(Point1,Point2,iNorm,vertA,vertB,vertC,radA,radB,radC)}

background {color White}
light_source { <20,20,-20> White shadowless}
camera{orthographic location <0,0,-10> look_at <0,0,0> }


Post a reply to this message

From: Bald Eagle
Subject: Re: parse error end of file but #end expected, is my code correct?
Date: 4 Dec 2017 02:25:00
Message: <web.5a24b0d81496c9fd5cafe28e0@news.povray.org>
Well, you were obviously missing an #end.
I indented the [many :O ] nested #if/#else/#end statements and commented the
#ends, and then added variable definitions before the invocation of the second
macro, but that macro doesn't yet define an object to be used in an object {}
statement...

This ought to get you most of the way there:


#version 3.71;
global_settings {
 assumed_gamma 1.0
 ambient_light 4
}


#include "colors.inc"
#include "shapes.inc"
#include "math.inc"

#macro round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT)

 //Joining lines

 #local EdgeRadius = 1;

 union {
    object{Round_Cone2(p3, r3, p1, r1, EdgeRadius)texture{rT}   }
    object{Round_Cone2(p1, r1, p2, r2, EdgeRadius)texture{bT}   }
    object{Round_Cone2(p2, r2, p3, r3, EdgeRadius)texture{gT}   }
 }
#end

//Triangle definitions

#declare p1 = <-5,0,0>;
#declare p2 = <5,4,0>;
#declare p3 = <-5,9,0>;
#declare r1 = 5;
#declare r2 = 3;
#declare r3 = 1;

//Colour Textures
#declare bT   = texture{ pigment {  rgb<0,0,1> } }     //Blue
#declare rT   = texture{ pigment {  rgb<1,0,0> } }     //Red
#declare gT   = texture{ pigment {  rgb<0,1,0> } }     //Green
#declare vT   = texture{ pigment {  rgb<0.5,0,1> }}    //Violet

object {round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT) }


#macro SF_roundtriangleintpoints
(Point1,Point2,iNorm,vertA,vertB,vertC,radA,radB,radC)
 //
 #local vertA = <-5,0,0>;
 #local vertB = <5,4,0>;
 #local vertC = <-5,9,0>;
 #local radA = 5;
 #local radB = 3;
 #local radC = 1;
 //
 #if(radA<=0)
  #local iNorm  = 0;
  #local Point1 = vertA;
  #local Point2 = vertA;
 #else
  #local AtoB       = vertB - vertA;
  #local ellAB      = vlength(AtoB);

   #if(ellAB>abs(radA-radB))
  // May not degenerate to a single roundcone
   #local AtoB       = AtoB/ellAB;
   #local cyl1AB     = vertA + radA*(radA - radB)*AtoB/ellAB;
   #local sinalphaAB = (radA - radB)/ellAB;
   // Given the #if condition, 0 < sinalphaAB < 1
   #local cosalphaAB = sqrt(1-sinalphaAB*sinalphaAB);
   #local AtoC       = vertC - vertA;
   #local ellAC      = vlength(AtoC);

   #if(ellAC>abs(radA-radC))
    // May not degenerate to a single roundcone
    #local AtoC       = AtoC/ellAC;
    #local cyl1AC     = vertA + radA*(radA - radA)*AtoC/ellAC;
    #local cyl2AC     = vertC + radC*(radA - radC)*AtoC/ellAC;
    #local sinalphaAC = (radA - radC)/ellAC;
    // Given the #if condition, 0 < sinalphAC < 1
    #local cosalphaAC = sqrt(1-sinalphaAC*sinalphaAC);
    #local cosbetaABC = vdot(AtoB,AtoC);

    #if(cosbetaABC > 1)
     #local cosbetaABC = 1;
    #end // end #if(cosbetaABC > 1)

    #local sinbetaABC = sqrt(1 - cosbetaABC*cosbetaABC);
    #local AtoBperpC  = AtoC - cosbetaABC*AtoB;
    #local lAtoBperpC = vlength(AtoBperpC);

    #if(lAtoBperpC > 0)
     #local AtoBperpC  = AtoBperpC/vlength(AtoBperpC);
    #end // end #if(lAtoBperpC > 0)

    #local ABCperp    = vcross(AtoB,AtoC);
    #local ABCArea    = vlength(ABCperp);

    #if(ABCArea > 0)
     #local ABCperp    = ABCperp/ABCArea;
     #local yABC       =
radA*((radA-radC)/ellAC-cosbetaABC*(radA-radB)/ellAB)/sinbetaABC;
     #local zABC       = radA*radA - yABC*yABC -
(radA*(radA-radB)/ellAB)*(radA*(radA-radB)/ellAB);
    #else
     #local zABC       = -1;
    #end // end #if(ABCArea > 0)

    #if(zABC>=0.000000001)
     // Didn't degenerate into a single roundcone
     #local zABC   = sqrt(zABC);
     #local iNorm  = 1;
     #local Point1 = cyl1AB + yABC*AtoBperpC + zABC*ABCperp;
     #local Point2 = cyl1AB + yABC*AtoBperpC - zABC*ABCperp;
    #else
     #local iNorm  = -1;
     #local Point1 = vertA;
     #local Point2 = vertA;
    #end // end #if(zABC>=0.000000001)

   #else
    #local iNorm  = -1;
    #local Point1 = vertA;
    #local Point2 = vertA;
   #end // end #if(ellAC>abs(radA-radC))

  #else
   #local iNorm  = -1;
   #local Point1 = vertA;
   #local Point2 = vertA;
  #end // end #if(ellAB>abs(radA-radB))
 #end // end #if(radA<=0)
#end // end macro

#declare Point1 = <0, 0, 0>;
#declare Point2 = <5, 5, 5>;
#declare iNorm = 1;
#declare vertA = <2, 2, 2>;
#declare vertB = <3, 3, 3>;
#declare vertC = <4, 4, 4>;
#declare radA = 0.25;
#declare radB = 0.35;
#declare radC = 0.1;

// Nowhere in the SF_roundtriangleintpoints do you actually define an object....

object {SF_roundtriangleintpoints (Point1, Point2, iNorm, vertA, vertB, vertC,
radA, radB, radC) }

background {color White}
light_source { <20,20,-20> White shadowless}
camera {orthographic location <0, 0, -10> look_at <0, 0, 0>}


Post a reply to this message

From: daisy807
Subject: Re: parse error end of file but #end expected, is my code correct?
Date: 4 Dec 2017 02:40:01
Message: <web.5a24b4aa1496c9fd4df778040@news.povray.org>
Thank you
im self teaching myself Pov-RAY finding it very difficult
so sf_roundtrianglepoints are just points i need so im guessing it shouldnt be
an object
i put the corrected code you produced onto pov ray and it worked but i cannot
see the points

altogether i need 6 points

really appreciate your help! :)

"Bald Eagle" <cre### [at] netscapenet> wrote:
> Well, you were obviously missing an #end.
> I indented the [many :O ] nested #if/#else/#end statements and commented the
> #ends, and then added variable definitions before the invocation of the second
> macro, but that macro doesn't yet define an object to be used in an object {}
> statement...
>
> This ought to get you most of the way there:
>
>
> #version 3.71;
> global_settings {
>  assumed_gamma 1.0
>  ambient_light 4
> }
>
>
> #include "colors.inc"
> #include "shapes.inc"
> #include "math.inc"
>
> #macro round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT)
>
>  //Joining lines
>
>  #local EdgeRadius = 1;
>
>  union {
>     object{Round_Cone2(p3, r3, p1, r1, EdgeRadius)texture{rT}   }
>     object{Round_Cone2(p1, r1, p2, r2, EdgeRadius)texture{bT}   }
>     object{Round_Cone2(p2, r2, p3, r3, EdgeRadius)texture{gT}   }
>  }
> #end
>
> //Triangle definitions
>
> #declare p1 = <-5,0,0>;
> #declare p2 = <5,4,0>;
> #declare p3 = <-5,9,0>;
> #declare r1 = 5;
> #declare r2 = 3;
> #declare r3 = 1;
>
> //Colour Textures
> #declare bT   = texture{ pigment {  rgb<0,0,1> } }     //Blue
> #declare rT   = texture{ pigment {  rgb<1,0,0> } }     //Red
> #declare gT   = texture{ pigment {  rgb<0,1,0> } }     //Green
> #declare vT   = texture{ pigment {  rgb<0.5,0,1> }}    //Violet
>
> object {round_cone_triangle ( p1, p2, p3,  r1, r2, r3, bT, rT, gT, vT) }
>
>
> #macro SF_roundtriangleintpoints
> (Point1,Point2,iNorm,vertA,vertB,vertC,radA,radB,radC)
>  //
>  #local vertA = <-5,0,0>;
>  #local vertB = <5,4,0>;
>  #local vertC = <-5,9,0>;
>  #local radA = 5;
>  #local radB = 3;
>  #local radC = 1;
>  //
>  #if(radA<=0)
>   #local iNorm  = 0;
>   #local Point1 = vertA;
>   #local Point2 = vertA;
>  #else
>   #local AtoB       = vertB - vertA;
>   #local ellAB      = vlength(AtoB);
>
>    #if(ellAB>abs(radA-radB))
>   // May not degenerate to a single roundcone
>    #local AtoB       = AtoB/ellAB;
>    #local cyl1AB     = vertA + radA*(radA - radB)*AtoB/ellAB;
>    #local sinalphaAB = (radA - radB)/ellAB;
>    // Given the #if condition, 0 < sinalphaAB < 1
>    #local cosalphaAB = sqrt(1-sinalphaAB*sinalphaAB);
>    #local AtoC       = vertC - vertA;
>    #local ellAC      = vlength(AtoC);
>
>    #if(ellAC>abs(radA-radC))
>     // May not degenerate to a single roundcone
>     #local AtoC       = AtoC/ellAC;
>     #local cyl1AC     = vertA + radA*(radA - radA)*AtoC/ellAC;
>     #local cyl2AC     = vertC + radC*(radA - radC)*AtoC/ellAC;
>     #local sinalphaAC = (radA - radC)/ellAC;
>     // Given the #if condition, 0 < sinalphAC < 1
>     #local cosalphaAC = sqrt(1-sinalphaAC*sinalphaAC);
>     #local cosbetaABC = vdot(AtoB,AtoC);
>
>     #if(cosbetaABC > 1)
>      #local cosbetaABC = 1;
>     #end // end #if(cosbetaABC > 1)
>
>     #local sinbetaABC = sqrt(1 - cosbetaABC*cosbetaABC);
>     #local AtoBperpC  = AtoC - cosbetaABC*AtoB;
>     #local lAtoBperpC = vlength(AtoBperpC);
>
>     #if(lAtoBperpC > 0)
>      #local AtoBperpC  = AtoBperpC/vlength(AtoBperpC);
>     #end // end #if(lAtoBperpC > 0)
>
>     #local ABCperp    = vcross(AtoB,AtoC);
>     #local ABCArea    = vlength(ABCperp);
>
>     #if(ABCArea > 0)
>      #local ABCperp    = ABCperp/ABCArea;
>      #local yABC       =
> radA*((radA-radC)/ellAC-cosbetaABC*(radA-radB)/ellAB)/sinbetaABC;
>      #local zABC       = radA*radA - yABC*yABC -
> (radA*(radA-radB)/ellAB)*(radA*(radA-radB)/ellAB);
>     #else
>      #local zABC       = -1;
>     #end // end #if(ABCArea > 0)
>
>     #if(zABC>=0.000000001)
>      // Didn't degenerate into a single roundcone
>      #local zABC   = sqrt(zABC);
>      #local iNorm  = 1;
>      #local Point1 = cyl1AB + yABC*AtoBperpC + zABC*ABCperp;
>      #local Point2 = cyl1AB + yABC*AtoBperpC - zABC*ABCperp;
>     #else
>      #local iNorm  = -1;
>      #local Point1 = vertA;
>      #local Point2 = vertA;
>     #end // end #if(zABC>=0.000000001)
>
>    #else
>     #local iNorm  = -1;
>     #local Point1 = vertA;
>     #local Point2 = vertA;
>    #end // end #if(ellAC>abs(radA-radC))
>
>   #else
>    #local iNorm  = -1;
>    #local Point1 = vertA;
>    #local Point2 = vertA;
>   #end // end #if(ellAB>abs(radA-radB))
>  #end // end #if(radA<=0)
> #end // end macro
>
> #declare Point1 = <0, 0, 0>;
> #declare Point2 = <5, 5, 5>;
> #declare iNorm = 1;
> #declare vertA = <2, 2, 2>;
> #declare vertB = <3, 3, 3>;
> #declare vertC = <4, 4, 4>;
> #declare radA = 0.25;
> #declare radB = 0.35;
> #declare radC = 0.1;
>
> // Nowhere in the SF_roundtriangleintpoints do you actually define an object....
>
> object {SF_roundtriangleintpoints (Point1, Point2, iNorm, vertA, vertB, vertC,
> radA, radB, radC) }
>
> background {color White}
> light_source { <20,20,-20> White shadowless}
> camera {orthographic location <0, 0, -10> look_at <0, 0, 0>}


Post a reply to this message

From: Bald Eagle
Subject: Re: parse error end of file but #end expected, is my code correct?
Date: 4 Dec 2017 11:35:00
Message: <web.5a25328f1496c9fd5cafe28e0@news.povray.org>
"daisy807" <dri### [at] livecouk> wrote:
> Thank you
> im self teaching myself Pov-RAY finding it very difficult

Well, you're off to a pretty amazing start.
I find it useful to visual pair each opening and closing of a block of code with
another level of indent, plus commenting which #end is which.
It's also helpful when writing blocks of code like that to immediately terminate
the block with the matching ending, and then insert the filler code afterwards -
so every opening always has a matching ending.

#if // if #1
     #if // # if #2
          some code
     #end // end if #2
#end // end if #1

That way I can lock my eyes on the opening, and scroll down until I hit the
close. (I need to start doing this with parentheses too)

I also do this with opening and closing curly braces for unions, textures, etc.

> so sf_roundtrianglepoints are just points i need so im guessing it shouldnt be
> an object
> i put the corrected code you produced onto pov ray and it worked but i cannot
> see the points
>
> altogether i need 6 points

You just need a sphere {} for every point.  Points in POV-Ray aren't visible
objects - even "if they were" - they'd be infinitely small mathematical points
that were invisible anyway  ;)
[back off pedants - you know what I mean! :D  ]

So just make a
#declare Triangle = union {sphere {}  sphere{}  sphere {}}
with very small radii, and that ought to do it.

> really appreciate your help! :)

Sure thing


Post a reply to this message

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