How to resolve the algorithm Superellipse step by step in the QB64 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Superellipse step by step in the QB64 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 QB64 programming language
Source code in the qb64 programming language
_Title "Super Ellipse"
Dim As Integer sw, sh
Dim As Single i
sw = 480: sh = 480
Screen _NewImage(sw, sh, 8)
Cls , 15
'Show different possible Super Ellipse shapes
Color 10
For i = 0.2 To 5.0 Step .1
Call SuperEllipse(sw \ 2, sh \ 2, 200, 200, i, 80)
Next
'Show task specified Super Ellipse
Color 0
Call SuperEllipse(sw \ 2, sh \ 2, 200, 200, 2.5, 200)
Sleep
System
Sub SuperEllipse (cX As Integer, cY As Integer, wide As Integer, high As Integer, pow As Double, segs As Integer)
Dim As Double power, inc, theta, cosTheta, sinTheta
Dim As Integer x1, y1
'Limit 'pow' to acceptable values
If pow < .1 Then pow = .1
If pow > 150 Then pow = 150
power = 2 / pow - 1
inc = 360.0 / segs * 0.0174532925199432957692369
PSet (wide + cX, cY)
For theta = inc To 6.28318530717958647692528 + inc Step inc
cosTheta = Cos(theta): sinTheta = Sin(theta)
x1 = wide * cosTheta * Abs(cosTheta) ^ power + cX
y1 = high * sinTheta * Abs(sinTheta) ^ power + cY
Line -(x1, y1)
Next
End Sub
You may also check:How to resolve the algorithm Evaluate binomial coefficients step by step in the Clojure programming language
You may also check:How to resolve the algorithm CRC-32 step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Calculating the value of e step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Idiomatically determine all the lowercase and uppercase letters step by step in the Perl programming language
You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the VTL-2 programming language