How to resolve the algorithm Superellipse step by step in the Action! programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Superellipse step by step in the Action! programming language
Table of Contents
Problem Statement
A superellipse is a geometric figure defined as the set of all points (x, y) with
where n, a, and b are positive numbers.
Draw a superellipse with n = 2.5, and a = b = 200
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Superellipse step by step in the Action! programming language
Source code in the action! programming language
INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
PROC Superellipse(INT x0 BYTE y0 REAL POINTER n BYTE a)
INT ARRAY f(100)
REAL ar,xr,tmp1,tmp2,tmp3,one,invn
INT x
IntToReal(1,one)
RealDiv(one,n,invn) ;1/n
IntToReal(a,ar)
Power(ar,n,tmp1) ;a^n
Plot(x0,y0-a)
FOR x=0 TO a
DO
IntToReal(x,xr)
Power(xr,n,tmp2) ;x^n
RealSub(tmp1,tmp2,tmp3) ;a^n-x^n
Power(tmp3,invn,tmp2) ;(a^n-x^n)^(1/n)
f(x)=RealToInt(tmp2)
DrawTo(x0+x,y0-f(x))
OD
x=a
WHILE x>=0
DO
DrawTo(x0+x,y0+f(x))
x==-1
OD
FOR x=0 TO a
DO
DrawTo(x0-x,y0+f(x))
OD
x=a
WHILE x>=0
DO
DrawTo(x0-x,y0-f(x))
x==-1
OD
RETURN
PROC Main()
BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6
REAL n
Graphics(8+16)
Color=1
COLOR1=$0C
COLOR2=$02
ValR("2.5",n)
Superellipse(160,96,n,80)
DO UNTIL CH#$FF OD
CH=$FF
RETURN
You may also check:How to resolve the algorithm Pan base non-primes step by step in the Raku programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the min programming language
You may also check:How to resolve the algorithm Strip control codes and extended characters from a string step by step in the Java programming language
You may also check:How to resolve the algorithm Hofstadter Figure-Figure sequences step by step in the Raku programming language
You may also check:How to resolve the algorithm Sorting algorithms/Merge sort step by step in the BCPL programming language