Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » batch files, graph plotting and

This thread is locked; no one can reply to it. rss feed Print
batch files, graph plotting and
William Labbett
Member #4,486
March 2004
avatar

Hi Allegators,

couple of things you might be able to help me with :

1) (dull) - is there an equivalent to a windows batch file for use with MSYS ?

2) Has anyone written a good graph plotter which uses allegro and I could use to plot some graphs ?

Help would be appreciated.

MiquelFire
Member #3,110
January 2003
avatar

1) Shell scripts. There's Linux tutorials on this.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

bamccaig
Member #7,536
July 2006
avatar

1) (dull) - is there an equivalent to a windows batch file for use with MSYS ?

Not really. Batch files are horrid. :P AFAIK, MSYS has a proper Bash shell implementation so you can use bash scripts, for example. Alternatively, there is probably a version of perl in MSYS that you could use too (or you could just install Strawberry Perl, a native implementation for Windows).

2) Has anyone written a good graph plotter which uses allegro and I could use to plot some graphs ?

If this question is related to the first, there are probably some useful Perl modules on CPAN to do graph plotting. :)

William Labbett
Member #4,486
March 2004
avatar

that's fab guys. thanks. I'll look into it all in due course.

MiquelFire
Member #3,110
January 2003
avatar

I just thought of something, depending on what you use the batch files for, you might be able to use Bash's alias command. Basically, within bash, you can have something like la be the same as typing ls -a. Just something to keep in mind.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

bamccaig
Member #7,536
July 2006
avatar

MiquelFire
Member #3,110
January 2003
avatar

Yea, I'm a bit random at times (like running the nyan.cat site in the background while I play TF2)

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

2) Has anyone written a good graph plotter which uses allegro and I could use to plot some graphs ?

I just finished some classes that parse written function strings into evaluatable equations. The next step is to graph them upon request. I may have something you could use here in a few days if I'm productive.

J-Gamer
Member #12,491
January 2011
avatar

@Edgar: Isn't a viable solution for this to calculate what the delta X for every pixel is( (maxX-minX)/GraphWidth with GraphWidth in pixels), step trough from the minimum X to the max X in steps of delta X and calculate the Y value for each pixel? (And, of course, only draw it when it is visible on the graph :))

" There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo
"If your body was a business, thought would be like micro-management and emotions would be like macro-management. If you primarily live your life with emotions, then you are prone to error on the details. If you over-think things all the time you tend to lose scope of priorities." - Mark Oates

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

That's the basic idea, yes.

Update
William - you still looking for a graphing program?

I've got basic plotting done along with function and expression evaluation on the command line. Type help inside the program to see available commands. When you use the plot command press ESC to go back to the console or CTRL S to save the plot as a png file.

FunctionEval.zip - static win32 exe
FunctionEval2.zip - updated version with LMB drag and scroll wheel zoom
Append
libpng-3.dll (forgot to upload this, you need it to run the program)

Some screenshots :

5*sin(x) + x
{"name":"604169","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/f\/dfd6242b30b30b7c3b1bc0448e757056.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/f\/dfd6242b30b30b7c3b1bc0448e757056"}604169

x^2 - 5
{"name":"604170","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/2\/42f86ad701a5b442b9a57d2fb0ee175e.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/2\/42f86ad701a5b442b9a57d2fb0ee175e"}604170

5*log(x)
{"name":"604171","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/f\/7fd2ffac77746eded374b07ba323e323.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/f\/7fd2ffac77746eded374b07ba323e323"}604171

I know the colors aren't the best, but I'll adjust that in the future. Other features planned include LMB dragging the view around, mouse wheel zooming, full graphs with guides and evaluation info, simplifying equations, derivatives and possibly integrals as well.

You might have to click back and forth between the windows to get the program to continue. Maybe some day I'll figure out a portable way to automatically change the window focus.

If you need any help with the commands let me know.

Basic operation :

>change res(1024,768)
>set range(-100,100,-100,100)
>f(x) = sin(x^3)
>plot f
>exit

Update 2
I updated the executable to include LMB dragging of the view, and added mouse wheel zooming.

Append
Uploaded libpng-3.dll in case you don't have it. I thought everything was statically linked but I was wrong.

William Labbett
Member #4,486
March 2004
avatar

Cool Edgar. As you know I've downloaded it.

I need to do a function :-

4(p + q) - pq = 0

will your program be able to do this in future.

I think such functions are called implicit functions.

J-Gamer
Member #12,491
January 2011
avatar

That OR needs a parameter OR you can work it out to an explicit one yourself. With this example it isn't hard.
4p + 4q - pq = 0
p(4-q) = -4q
p = -4q/(4-q)

" There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo
"If your body was a business, thought would be like micro-management and emotions would be like macro-management. If you primarily live your life with emotions, then you are prone to error on the details. If you over-think things all the time you tend to lose scope of priorities." - Mark Oates

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

At this point I hadn't planned on trying to solve equations, rather just evaluate expressions and plot functions. It is not a simple thing to teach a program how to solve for variables.

However, after doing what J-Gamer did by solving the equation himself you could then enter the equation and evaluate it for any p or plot p as x and the result as y :

f(q) = -4*q/(4 - q)
f(0)
f(1)
plot f

I may update the program sometime later today, as I fixed a bug where negative numbers were being displayed as positive, fixed a couple small parsing bugs, and I am making some progress on simplifying equations.

Go to: