Power-function curves

Discussions related to mathematics, numerical methods, graph plotting etc.
Richard Russell
Posts: 457
Joined: Tue 18 Jun 2024, 09:32

Power-function curves

Post by Richard Russell »

These curves are of various powers of x, from the tenth-root of x (y = x^0.1) at the top, then ninth-root through square-root (y = x^0.5), then y = x in the middle, y = x² through y = x⁹ and finally y = x¹⁰ at the bottom. They make a nicely symmetrical set.

This is a good demonstration of anti-aliasing, since these curves would look quite nasty plotted with jaggy, pixellated, graphics.

The program will run equally well in BBC BASIC for SDL 2.0 and BBC BASIC for Windows (so long as it's new enough to include the AAGFXLIB library).

Code: Select all

   10 INSTALL @lib$ + "aagfxlib"
   20 ORIGIN 140,2
   30 segs% = 128
   40 DIM x(segs%), y(segs%)
   50 FOR e% = -9 TO 9
   60   FOR i% = 1 TO segs%
   70     x = i% / segs%
   80     IF e% >= 0 y = x ^ (e%+1) ELSE y = x ^ (1/(1-e%))
   90     x(i%) = 1000 * x
  100     y(i%) = 1000 * y
  110   NEXT
  120   C% = &FF000000 OR e% * &56789A
  130   PROC_aapolyline(segs% + 1, x(), y(), 1.5, C%, 0)
  140 NEXT e%
onion.png
You do not have the required permissions to view the files attached to this post.