POV-Ray : Newsgroups : povray.binaries.images : graphing calculator - why not :) Server Time
5 Nov 2024 02:22:36 EST (-0500)
  graphing calculator - why not :) (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: Charles C
Subject: graphing calculator - why not :)
Date: 15 Dec 2005 15:20:01
Message: <web.43a1cea9363166ed2ed1de200@news.povray.org>
All I can say is "why not." Calculators cost money but you can make one for
free.  Actually I have my old HP48 but wanted to do this anyway.

Where I got stuck before (this is an old project which I recently came back
to) was that I needed to be able to have a whole arbitrary expression as a
string that I could display as well as evaluating it to a float that I
could plot.  val() of course can convert a string literal to a float, but
val("2+2") returns the number 2.

It seemed somewhat cumbersome to do so, but I finally gave in and outputted
strings to a file, to be read back in as a macro holding an expression.
Here's that macro to create the temp file:

#macro Make_Temporary_Expression_Macro_File(Eq)
        #fopen  Calculator_Temp_Expression_File
"Temporary_Expression_Macro_File.tmp"  write
        #write (Calculator_Temp_Expression_File, "/* This is a temporary
file generated and used by calculator.pov and can be deleted without harm.
*/n")
        #write (Calculator_Temp_Expression_File, "#macro Evaluate_Eq_For_X
(X)  n")
        #write (Calculator_Temp_Expression_File, "      #declare Eq_Y = " )
        #write (Calculator_Temp_Expression_File, Eq ) //the function
        #write (Calculator_Temp_Expression_File, "; n#end n" )
        #fclose Calculator_Temp_Expression_File
#end // end  Make_Temporary_Expression_Macro_File

Any better ideas?  The little temp file gets written over once for each
function and once for each expression.

The way it is now the calculator will display up to 10 funtions, and 10
expressions with their evaluated answers.  Functions can be displayed as
either lines or dots, line thickness can be set for each function as well
as how frequently along the x-axis the funtion is evaluated. (200 times
seems like a good number for most.)

The viewable region is adjustable (-2*pi to 2*pi for x and -2 to 2 for y as
displayed here) and each funtion will only be plotted where they coincide
with that region; they do not get scaled independantly as they don't have
independant ranges.  I also haven't gotten around to making auto-adjusting
hash marks for the axis yet.

Thanks,
Charles


Post a reply to this message


Attachments:
Download 'calculator.png' (79 KB)

Preview of image 'calculator.png'
calculator.png


 

From: John VanSickle
Subject: Re: graphing calculator - why not :)
Date: 15 Dec 2005 20:06:40
Message: <43a21320$1@news.povray.org>
Charles C wrote:

> All I can say is "why not." Calculators cost money but you can make one for
> free.  Actually I have my old HP48 but wanted to do this anyway.
> 
> Where I got stuck before (this is an old project which I recently came back
> to) was that I needed to be able to have a whole arbitrary expression as a
> string that I could display as well as evaluating it to a float that I
> could plot.  val() of course can convert a string literal to a float, but
> val("2+2") returns the number 2.
> 
> It seemed somewhat cumbersome to do so, but I finally gave in and outputted
> strings to a file, to be read back in as a macro holding an expression.
> Here's that macro to create the temp file:
> 
> #macro Make_Temporary_Expression_Macro_File(Eq)
>         #fopen  Calculator_Temp_Expression_File
> "Temporary_Expression_Macro_File.tmp"  write
>         #write (Calculator_Temp_Expression_File, "/* This is a temporary
> file generated and used by calculator.pov and can be deleted without harm.
> */n")
>         #write (Calculator_Temp_Expression_File, "#macro Evaluate_Eq_For_X
> (X)  n")
>         #write (Calculator_Temp_Expression_File, "      #declare Eq_Y = " )
>         #write (Calculator_Temp_Expression_File, Eq ) //the function
>         #write (Calculator_Temp_Expression_File, "; n#end n" )
>         #fclose Calculator_Temp_Expression_File
> #end // end  Make_Temporary_Expression_Macro_File
> 
> Any better ideas?  The little temp file gets written over once for each
> function and once for each expression.

I did something like this for an AmigaBasic program about a dozen years 
ago.  I had the program use RPN for the expressions, because they're 
much simpler to parse.

Regards,
John


Post a reply to this message

From: Charles C
Subject: Re: graphing calculator - why not :)
Date: 16 Dec 2005 00:55:00
Message: <web.43a2562411ef9f355c0503730@news.povray.org>
Hehe I like reverse polish on my HP, but I wanted to take advantage of
whatever POV already knew how to do... E.g. any function or user created
macro that can return a float will work.   For a while I was considering
making a string parser (a string parser within a parsed-string/sdl!) to
read in the numbers digit by digit and so on, but I thought that'd be a lot
more work than doing this writing a file and reading it back.  Actually
back in college I did write such a parser for a C class but it only
supported the basic +-/x%


Post a reply to this message

From: Rick Measham
Subject: Re: graphing calculator - why not :)
Date: 16 Dec 2005 01:27:44
Message: <43a25e60@news.povray.org>
Charles C wrote:
> Hehe I like reverse polish on my HP

Is reverse polish done with something like this??

finish{
	phong -1
}

Cheers!
Rick Measham


Post a reply to this message

From: Joanne Simpson
Subject: Re: graphing calculator - why not :)
Date: 16 Dec 2005 02:15:00
Message: <web.43a2694e11ef9f35dc45bc820@news.povray.org>
Rick Measham <rickm*at%isite.net.au> wrote:
> Charles C wrote:
> > Hehe I like reverse polish on my HP
>
> Is reverse polish done with something like this??
>
> finish{
>  phong -1
> }
>
> Cheers!
> Rick Measham

almost...

#declare notation =
finish{
 phong -1
        roughness 1
}


Post a reply to this message

From: Zeger Knaepen
Subject: Re: graphing calculator - why not :)
Date: 16 Dec 2005 05:36:53
Message: <43a298c5$1@news.povray.org>
"Joanne Simpson" <cor### [at] onewhiteravencom> wrote in message 
news:web.43a2694e11ef9f35dc45bc820@news.povray.org...
> Rick Measham <rickm*at%isite.net.au> wrote:
> > Charles C wrote:
> > > Hehe I like reverse polish on my HP
> >
> > Is reverse polish done with something like this??
> >
> > finish{
> >  phong -1
> > }
> >
> > Cheers!
> > Rick Measham
> 
> almost...
> 
> #declare notation =
> finish{
>  phong -1
>         roughness 1
> }

I'm quite sure roughness has no effect on phong, only on specular, but I 
might be wrong of course :)

cu!
-- 
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x)            // ZK http://www.povplace.com


Post a reply to this message

From: Marc Jacquier
Subject: Re: graphing calculator - why not :)
Date: 16 Dec 2005 09:22:20
Message: <43a2cd9c$1@news.povray.org>

news:43a298c5$1@news.povray.org...
I'm quite sure roughness has no effect on phong, only on specular, but I
might be wrong of course :)

I think you're right, IIRC, the corresponding parameter for phong is
phong_size
Marc


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: graphing calculator - why not :)
Date: 16 Dec 2005 16:36:15
Message: <43a3334f@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joanne Simpson wrote:
> Rick Measham <rickm*at%isite.net.au> wrote: 
>>Charles C wrote:
>>
>>Is reverse polish done with something like this??
>>
>>finish{
>> phong -1
>>}
>> 
> almost...
> 
> #declare notation =
> finish{
>  phong -1
>         roughness 1
> }
> 
	Nonono, reverse polish is done with this:
- -1
phong
1
phong_size
finish

	;)
		Jerome

- --
******************************
*      Jerome M. Berger      *
*  mailto:jeb### [at] freefr   *
*  http://jeberger.free.fr/  *
******************************
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDozNOqIYJdJhyixIRAub+AKCf98kThdJ8BoEUINFQ9dmf4QA1RwCfYkRB
rC3rYx13ylcG23xj9aicVt8=
=xhQQ
-----END PGP SIGNATURE-----


Post a reply to this message

From: Jörg 'Yadgar' Bleimann
Subject: Re: graphing calculator - why not :)
Date: 16 Dec 2005 17:38:26
Message: <43a341e2$1@news.povray.org>

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
High!

> 	Nonono, reverse polish is done with this:
> - -1
> phong
> 1
> phong_size
> finish
> 
> 	;)


Hehe... the whole sub-thread wouldn't have started if Charles had used 
an upper case "p" for his "polish"... back in 1984, I read in the 
then-popular German computer magazine "RUN" an article about Forth, a 
programming language which just had been made available for the 
Commodore 64. I really do not know much about Forth, but I remember that 
its design strongly is based on stacks, which leads to a syntax which is 
rather strange compared to other programming language: the "Inverted 
Polish Notation". Obviously, (one of) the mathematician(s) who invented 
Forth hailed from Poland...

See you in Khyberspace!

Yadgar

Now playing: Tel Aviv (Duran Duran)


Post a reply to this message

From: Mike Williams
Subject: graphing calculator - why not :)
Date: 16 Dec 2005 20:45:53
Message: <xRl$LQAK02oDFwQQ@econym.demon.co.uk>


>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>High!
>
>>      Nonono, reverse polish is done with this:
>> - -1
>> phong
>> 1
>> phong_size
>> finish
>> 
>>      ;)
>
>
>Hehe... the whole sub-thread wouldn't have started if Charles had used 
>an upper case "p" for his "polish"... back in 1984, I read in the 
>then-popular German computer magazine "RUN" an article about Forth, a 
>programming language which just had been made available for the 
>Commodore 64. I really do not know much about Forth, but I remember that 
>its design strongly is based on stacks, which leads to a syntax which is 
>rather strange compared to other programming language: the "Inverted 
>Polish Notation". Obviously, (one of) the mathematician(s) who invented 
>Forth hailed from Poland...
>
>See you in Khyberspace!

The term "Reverse Polish Notation" was coined by Hewlett-Packard
engineers to describe the method used in their early calculators. I
guess they had trouble pronouncing "Reverse Lukasiewicz Notation". (The
"L" should be pronounced something like a "W")

http://www-history.mcs.st-and.ac.uk/Mathematicians/Lukasiewicz.html

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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