Calculus - Conics, Parametric Equation, and Polar Coordinates

77 views
Skip to first unread message

Bert Mariani

unread,
Feb 16, 2024, 11:59:15 AMFeb 16
to The Ring Programming Language
Hello Mahmoud et ALL

Calculus - Conics, Parametric Equations, and Polar Coordinates
This App will draw the different Conic figures 
Using either Cartesian coordinates, or the easier to use Polar coordinates 

   - Calculus-Conics-1.ring
   - ConicFigures-ZIP.zip            ( mini-images)

Select a "Figure" from the drop down - top-left
"Start/Clear" to do the points calculation. It will call "DrawMatrix"
"DrawMatrix" can do repeated calls, if you wish to change angles, etc

The "DefaultParms" is enabled to use built in parameters
The "OneDraw" can be check to clear the screen for every repeated draw.

The  parameters X, Y, Z etc can be changed -- for size and position of calculated figure
Do a "Start/Clear" to recalculate afterwards.

The following figures are on the Drop-Down list
"Figure"            
"Ellipse"          
"Circle"            
"Parabola"          
"Hyperbola"        

"C-Spheroid"        
"P-Spheroid2"      
"P-Cylinder2"      

"C-Ellipsoid"      
"P-Ellipsoid2"      
"P-EllipticalCone2"

"P-EllipticalParaboloid2"
"P-HyperbolicParaboloid2"
"P-HyperbolicOneSheet2"  
"P-HyperbolicTwoSheet2"  

"P-Circle"      
"P-Signature"  
"P-Square"      
"P-SunPoints"  
"P-Umbrella"    
"P-PinWheel"    
"P-Turbine"    
"P-Butterfly"  

"Plane"   


Calculus-Conics.png

Calculus-Conics-1.ring
ConicFigures-ZIP.zip

Mahmoud Fayed

unread,
Feb 16, 2024, 6:07:33 PMFeb 16
to The Ring Programming Language
Hello Bert

Very nice application that can draw many figures. 


Attached a screen shot from my computer
niceshot.png

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Bert Mariani

unread,
Feb 20, 2024, 11:33:25 AMFeb 20
to The Ring Programming Language
Hello Mahmoud et ALL

A general comment on the Speed of an application - can it be Improved ?
Starting with a Ring program that works and runs ... can the speed be improved ?  (1 X)
Yes it can !  By looking at which section is invoked most often, the algorithm can be improved. (8 X)

Can the section further be improved by writing a  C-CALL using the Ring-to-C Interface ? (228 X,  27 X)
Yes it can ! Especially for iterative calculations.

Imagine having a Laptop that is 30 X faster !

========================
CACULUS-CONIC  SPEED Improvement and Comparison

- Using Ring   2.741 sec   1.00X  -.--X Calc TransformEq for EACH Pixel and Apply to Each Pixel
- Using RING   0.328 sec   8.35X  1.00X Calc TransformEq ONCE and Apply to Each Pixel
- Using C-CALL 0.012 sec 228.41X 27.33X Calc TransformEq ONCE and Apply to Each Pixel

//-----------------------------------------------------------------------------------------
CALCULUS-CONICS-1.ring   Algorithm -- Calc Transform for Each Picxel -- Apply to Each Pixel

QPixmap::scaled: Pixmap is a null pixmap
ConicEq: P-HyperbolicTwoSheet2 a= 2 b= 2 c= 2 h= 0 k= 0 d= 0 C= 0 I= 0.0400
New MC size: 12483

Calc.Transform Pixels....:   Total Time: 2.7470 seconds
Calc.Transform Pixels....:   Total Time: 2.7320 seconds
Calc.Transform Pixels....:   Total Time: 2.7410 seconds    Speed 1.00 X

//------------------------------------------------------------------------------
CALCULUS-CONICS-1.ring   Algorithm -- Calc Transform ONCE -- Apply to Each Pixel

QPixmap::scaled: Pixmap is a null pixmap
ConicEq: P-HyperbolicTwoSheet2 a= 2 b= 2 c= 2 h= 0 k= 0 d= 0 C= 0 I= 0.0400
New MC size: 12483

Calc.Transform Pixels....:   Total Time: 0.3350 seconds
Calc.Transform Pixels....:   Total Time: 0.3310 seconds
Calc.Transform Pixels....:   Total Time: 0.3280 seconds    Speed 8.35 X    

//----------------------------------------------------------------------------------------------
CALCULUS-CONICS-2.ring   Algorithm -- USING C-CALL -- Calc Transform ONCE -- Apply to Each Pixel

Loading Library - the DLL for the mylibTransformEq()
Windows loaded mylibTransformEq.dll
QPixmap::scaled: Pixmap is a null pixmap
ConicEq: P-HyperbolicTwoSheet2 a= 2 b= 2 c= 2 h= 0 k= 0 d= 0 C= 0 I= 0.0400
New MC size: 12483

Calc.Transform Pixels....:   Total Time: 0.0230 seconds
Calc.Transform Pixels....:   Total Time: 0.0110 seconds
Calc.Transform Pixels....:   Total Time: 0.0120 seconds    Speed 228.41 X   Speed 27.33 X

//-----------------------------------------------------------------------------------------

Mahmoud Fayed

unread,
Feb 21, 2024, 8:26:13 AMFeb 21
to The Ring Programming Language
Hello Bert

>> "A general comment on the Speed of an application - can it be Improved"

Nice analysis, Thanks for sharing :D

Greetings,
Mahmoud

Bert Mariani

unread,
Apr 5, 2024, 2:31:40 PMApr 5
to The Ring Programming Language
Hello Mahmoud et ALL

This is an update ... it has Animation ... 
It can draw more figures and quicker
=============================
- Calculus-Conics-2.ring       
- ConicFigures-ZIP.zip
- mylibCalcTransform.c                    => C-calculator for speed
- buildvc-mylibCalcTransform.bat   => Creates DLL required ( can not be attached so code follows)
       cls    
       call c:\ring\language\src\locatevc.bat x64    
       cl /c /DEBUG mylibCalcTransform.c   -I "C:\ring\language\include"
       link  /DEBUG mylibCalcTransform.obj     c:\ring\lib\ring.lib /DLL /OUT:mylibCalcTransform.dll
       del mylibCalcTransform.obj
       pause
==========================
Example: Snail Shell
  - Select drop-down figure
  - Start/Clear
  - Animation
  - Inc-Angle (default 1,1,1) can be used to change rotate amounts in X-Y-Z plane.
         - Try 0,0,1 for rotation around Z-plane

SnailShell.png




ConicFigures-ZIP.zip
Calculus-Conics-2.ring
mylibCalcTransform.c

Mahmoud Fayed

unread,
Apr 5, 2024, 11:42:34 PMApr 5
to The Ring Programming Language
Hello Bert

Thank you very much for the update :D

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Apr 6, 2024, 12:03:12 AMApr 6
to The Ring Programming Language
Hello Bert

Thanks again for this great update and wonderful animations :D


Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages