Paraboloid of revolution

By 2ARC

Supporter (11)

2ARC의 아바타

14-08-2021, 17:22

Hi all,

I´m starting Calculus II this week and I´m trying to put a simple graph on screen 5
It´s a Paraboloid of revolution expressed as f(x, y) = x² + y²
This is how it looks like in BASIC:
https://imgur.com/a/FavVh71
https://imgur.com/a/RsBfMA1

Now in msx-c this error occurs:
https://imgur.com/a/2SBdiID

There is a #include "math.h" at the top of source file. Maybe function has another name? Or is at another header file? Search google for sqrt in msx-c returns standard c examples. I know msx-c is not really ANSI C but I would like not to use assembler if possible. Anyway, this is just for fun and to get knowledge.

Thanks in advance.

Login or 등록 to post comments

By enribar

Paragon (1137)

enribar의 아바타

14-08-2021, 18:22

Simply, your version of MSX-C does not contain the complete libraries. Please update to the last version of MSX-C or skip to Fusion-C.

By 2ARC

Supporter (11)

2ARC의 아바타

14-08-2021, 18:27

OK. Thank you.

By 2ARC

Supporter (11)

2ARC의 아바타

14-08-2021, 18:35

Found this https://www.youtube.com/watch?v=WlOnX2uqRxE

It´s you, isnt it?

By enribar

Paragon (1137)

enribar의 아바타

15-08-2021, 10:06

I'm not the author of that tutorial but Eric Boez, see here:
https://www.ebsoft.fr/shop/en/19-fusion-c
That video is a good starting point :nishi:

By 2ARC

Supporter (11)

2ARC의 아바타

16-08-2021, 20:00

Yes, it is. Thank you. I´ll dive into it soon.

By 2ARC

Supporter (11)

2ARC의 아바타

18-08-2021, 16:24

Hi all,
Well, I know this might be well known, but just to sumarize what I found and to help anyone in the future (better jump directly into Fusion-C, I guess).
Maths functions are cumbersome in MSX-C, double and long (or XDOUBLE, SLONG) are not defined as types in the language like int, sqrt() is named xdsqrt(*ans, *number) and many more at mathmac.mac
Any way, this example shows what I mean. It seems when you call a math function the value at any pointer is cleanned, so I have to use a tmp variable. It worthed the fun, although.
P.s.: the includes are between < > not " "

#include "stdio.h"
#include "math.h"

main()
{
	/* 8 bytes long number in the form of a pointer */
	XDOUBLE a,b,ans,pi,tmp;
	/* Passing string formatted value to the pointer */
	atoxd(&a,"2.0");
	atoxd(&b,"3.0");
	atoxd(&pi,"3.141592");
	/**/
	printf("Number a = %3.2f\n",&a);
	printf("Number b = %3.2f\n",&b);	
	xdadd(&tmp,&a,&b);
	/* Square root*/
	xdsqrt(&ans,&a);
	printf("sqrt(a) = %3.2f\n",&ans);
	xdsqrt(&ans,&b);
	printf("sqrt(b) = %3.2f\n",&ans);
	/**/
	xdmul(&ans,&pi,&tmp);
	printf("5pi = %4.5f\n",&ans);
}