Wow
My math is so poor but my eyes remains always so fascinated looking at what math can do.
Thanks so much
suppose someone tell you to plot this equation
Pow(x,4) + Pow(y,4) + Pow(z,4) - Pow(x*x + y*y + z*z,2) + 3 * (x*x + y*y + z*z) = 0
and you don't have any clue how to solve it first such as saying:
z = f(x,y) , so how to plot it ?
there is a plan: is to search the points in space one by one in which this equation is approximately true such as:
If k <= 0.1 And k >= -0.1 Then ...
k is the value of the equation.
change it to:
If k <= 0.5 And k >= -0.5 Then
and you get a thicker surface curve with more points.
now if we tried the above equation but replacing Pow to '^' (uncomment line 178 ) then the time is twice than if use Pow. this is not important issue since we can use the speedier version.
try equation in line 175:
k = Sin(x*y)+Sin(y*z)+Sin(z*x)
it is ineresting
in line 217 : TBGL_PointSize 2 : make it 1 or 3 as necessary
change the range in line 162 as the plotting needed
this is an experimental mathematics
i have used the Entity System to position and rotate and look at using Entity system examples by Petr ,2009
also using Oxygen module to speed the calculations
you may wait from 6 to 30 seconds for every graphics since we check every point in the space within the range.
surface.JPGsurface1.JPG
'Experimental Mathematics = '=============================================================================== Uses "TBGL" , "Math" , "Oxygen" #Include Once "%APP_INCLUDEPATH%\thinbasic_gl.inc" #Include Once "%APP_INCLUDEPATH%\thinbasic_glu.inc" BEGIN CONST ' -- Scene IDs %sScene = 1 ' -- Entity IDs %eCamera = 1 %eContour %eLight %texOne %lMyPoints End Const Type Point3D x As Single y As Single z As Single red As Single green As Single blue As Single tu As Single tv As Single End Type Global Nb As DWord = 2000000 '401880 '8120601 Global x, y, z,zz As Single Global FrameRate As Long Global Vertex(Nb) As Point3D ' single Global total As Long 'Global ColorA(Nb) As TBGL_TRGB ' Byte FUNCTION TBMAIN() LOCAL hWnd As DWORD Global FrameRate As Double Global ang, earthX, earthZ, OrbitRadius As Single Global flag, mask As Long flag = 1 : mask = 1 OrbitRadius = 2.5 ' -- Create and show window hWnd = TBGL_CreateWindowEx("press Space to toggle the camera position , press 'M' to set a mask , 'R' reset mask to default ", 800, 600, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) TBGL_ShowWindow ' -- Create scene TBGL_SceneCreate(%sScene) ' -- Create basic entities ' -- Create camera to look from 0, 8, 20 to 0, 0, 0 TBGL_EntityCreateCamera(%sScene, %eCamera) TBGL_EntitySetPos(%sScene, %eCamera, 0, 8, 20) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) ' -- Create point light TBGL_EntityCreateLight(%sScene, %eLight) TBGL_EntitySetPos(%sScene, %eLight, 10, 20, 50) ' -- Create something to look at '---Start time Dim T0 As Double = Timer CreatePointsList() Dim T1 As Double = Timer MsgBox(0, "Total time to create points List " & Format$(T1 - T0, "#0.00") & " secs" & " ... number of points = " & Str$(total)) TBGL_EntityCreateDLSlot(%sScene, %eContour, 0, %lMyPoints) TBGL_EntitySetColor(%sScene, %eContour, 255, 255, 255) ' -- Resets status of all keys TBGL_ResetKeyState() TBGL_EntitySetTexture(%sScene, %eContour, %texOne ) 'TBGL_LoadTexture APP_Path+"SampleScripts\TBGL\GBuffers\Textures\Bricks.bmp", %texOne, %TBGL_TEX_MIPMAP TBGL_LoadTexture APP_Path+"SampleScripts\UI\Dialogs\Images\frogduck.bmp", %texOne, %TBGL_TEX_MIPMAP ' -- Main loop While TBGL_IsWindow(hWnd) FrameRate = TBGL_GetFrameRate TBGL_SetWindowTitle( hWnd, "FPS = "+Str$(FrameRate)+" press Space to toggle the camera position , press 'M' to set a mask , 'R' reset mask to default ") TBGL_ClearFrame If TBGL_GetWindowKeyOnce( hWnd, %VK_SPACE) Then If flag = 1 Then TBGL_EntitySetPos(%sScene, %eCamera, 0, 25, 0.1) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) flag * -1 Else TBGL_EntitySetPos(%sScene, %eCamera, 0, 12, 20) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) flag * -1 End If End If If TBGL_GetWindowKeyOnce( hWnd, %VK_M) Then If mask = 1 Then TBGL_EntitySetColorMask(%sScene, %eCamera, %TBGL_RED ) mask * -1 Else TBGL_EntitySetColorMask(%sScene, %eCamera, %TBGL_GREEN ) mask * -1 End If End If If TBGL_GetWindowKeyOnce( hWnd, %VK_R) Then TBGL_EntitySetColorMask(%sScene, %eCamera, %TBGL_DEFAULT) End If TBGL_EntitySetRot(%sScene, %eContour, 0, GetTickCount/40, 0) TBGL_SceneRender(%sScene) TBGL_DrawFrame ' -- ESCAPE key to exit application If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While Wend TBGL_DestroyWindow END FUNCTION '================================== Sub CreatePointsList() String src = " ' -- Re-declare types Type Point3D x As Single y As Single z As Single red As Single green As Single blue As Single tu As Single tv As Single End Type dim oVertex(2000000) At #Vertex As Point3D dim oTexA(2000000)At #TexA As Point3D dim N At #total As long 'dim oColorA(2000000) At #ColorA As TBGL_TRGB Long a, b, c, Nb Single x, z, k, xMin, yMin, zMin, xMax, yMax, zMax, range, step1 Long NbX Long NbZ Long NbY nbx = 300 nby = 300 nbz = 300 'xMin = -2 : yMin = -2: zMin = -2 : xMax = 2: yMax = 2 : zMax = 2 'xMin = -3 : yMin = -3: zMin = -3 : xMax = 3: yMax = 3 : zMax = 3 xMin = -4 : yMin = -4: zMin = -4 : xMax = 4: yMax = 4 : zMax = 4 'xMin = -5 : yMin = -5: zMin = -5 : xMax = 5: yMax = 5 : zMax = 5 range = xMax - xMin step1 = range / NbX x = xMin: z = zMin : y = yMin N = 0 For c = 0 To NbY For b=0 To NbZ For a=0 To NbX 'k = 320*(((x*x + (9*y*y)/4 +z*z -1)^3) - x*x*z*z*z - (9*y*y*z*z*z)/80) 'k = Sin(x*y)+Sin(y*z)+Sin(z*x) 'k = x^3+y^2+z^2 k = Pow(x,4) + Pow(y,4) + Pow(z,4) - Pow(x*x + y*y + z*z,2) + 3 * (x*x + y*y + z*z) 'k = x^4 + y^4 + z^4 - (x^2 + y^2 + z^2)^2 + 3 * (x^2 + y^2 + z^2) If k <= 0.1 And k >= -0.1 Then 'If k <= 0.5 And k >= -0.5 Then N = N+1 oVertex(N).x = x oVertex(N).y = y oVertex(N).z = z oVertex(N).tu = a/NbX oVertex(N).tv = b/Nbz End If x = x + step1 Next a x = xMin z = z + step1 Next b x = xMin z = zMin y = y + step1 Next c 'print str N terminate " ' -- Pass the source 'O2_Asmo src o2_basic src If Len(o2_error) Then MsgBox 0, o2_error : Stop End If ' -- Execute o2_exec Long N TBGL_NewList %lMyPoints TBGL_PointSize 2 TBGL_UseLighting %FALSE TBGL_BeginPoly %GL_POINTS For N=1 To Nb glTexCoord2f(Vertex(N).tu, Vertex(N).tv) glVertex3f(Vertex(N).x,Vertex(N).y,Vertex(N).z) Next TBGL_EndPoly TBGL_EndList TBGL_UseLighting %TRUE End Sub
Last edited by primo; 12-10-2017 at 17:50.
Wow
My math is so poor but my eyes remains always so fascinated looking at what math can do.
Thanks so much
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Sorry if I ask but it would be great to have arrow keys navigate inside the object moving in 3D
Curves.jpg
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
yes Eros , here is the navigation with the camera with arrows,
up/down: go inside/outside
left/right
A/Z: up/down
there is still the camera rotation with the Mouse+keys
now i think the while/wend is better than For/Next since we can decide how much points we need, will look at later.
in fact i like to Generate the Average 3D Face:
http://www1.cs.columbia.edu/~jebara/...IS/node48.html
there is a matrix , who have any idea will be great.
'Experimental Mathematics = '=============================================================================== Uses "TBGL" , "Math" , "Oxygen" #Include Once "%APP_INCLUDEPATH%\thinbasic_gl.inc" #Include Once "%APP_INCLUDEPATH%\thinbasic_glu.inc" Begin Const ' -- Scene IDs %sScene = 1 ' -- Entity IDs %eCamera = 1 %eContour %eLight %texOne %lMyPoints End Const Type Point3D x As Single y As Single z As Single red As Single green As Single blue As Single tu As Single tv As Single End Type Global Nb As DWord = 2000000 '401880 '8120601 Global x, y, z, xx, yy,zz As Single Global FrameRate As Long Global Vertex(Nb) As Point3D ' single Global total As Long 'Global ColorA(Nb) As TBGL_TRGB ' Byte Function TBMain() Local hWnd As DWord Global FrameRate As Double Global ang, earthX, earthZ, OrbitRadius As Single Global flag, mask As Long flag = 1 : mask = 1 OrbitRadius = 2.5 ' -- Create and show window hWnd = TBGL_CreateWindowEx("press Space to toggle the camera position , press 'M' to set a mask , 'R' reset mask to default ", 800, 600, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) TBGL_ShowWindow ' -- Create scene TBGL_SceneCreate(%sScene) ' -- Create basic entities ' -- Create camera to look from 0, 8, 20 to 0, 0, 0 TBGL_EntityCreateCamera(%sScene, %eCamera) TBGL_EntitySetPos(%sScene, %eCamera, 0, 8, 20) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) ' -- Create point light TBGL_EntityCreateLight(%sScene, %eLight) TBGL_EntitySetPos(%sScene, %eLight, 10, 20, 50) ' -- Create something to look at '---Start time Dim T0 As Double = Timer CreatePointsList() Dim T1 As Double = Timer MsgBox(0, "Total time to create points List " & Format$(T1 - T0, "#0.00") & " secs" & " ... number of points = " & Str$(total)) TBGL_EntityCreateDLSlot(%sScene, %eContour, 0, %lMyPoints) TBGL_EntitySetColor(%sScene, %eContour, 255, 255, 255) ' -- Resets status of all keys TBGL_ResetKeyState() TBGL_EntitySetTexture(%sScene, %eContour, %texOne ) 'TBGL_LoadTexture APP_Path+"SampleScripts\TBGL\GBuffers\Textures\Bricks.bmp", %texOne, %TBGL_TEX_MIPMAP TBGL_LoadTexture APP_Path+"SampleScripts\UI\Dialogs\Images\frogduck.bmp", %texOne, %TBGL_TEX_MIPMAP ' -- Main loop While TBGL_IsWindow(hWnd) FrameRate = TBGL_GetFrameRate TBGL_SetWindowTitle( hWnd, "FPS = "+Str$(FrameRate)+" press Space to toggle the camera position , press 'M' to set a mask , 'R' reset mask to default ") TBGL_ClearFrame If TBGL_GetWindowKeyOnce( hWnd, %VK_SPACE) Then If flag = 1 Then TBGL_EntitySetPos(%sScene, %eCamera, 0, 25, 0.1) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) flag * -1 Else TBGL_EntitySetPos(%sScene, %eCamera, 0, 12, 20) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) flag * -1 End If End If If TBGL_GetWindowKeyOnce( hWnd, %VK_M) Then If mask = 1 Then TBGL_EntitySetColorMask(%sScene, %eCamera, %TBGL_RED ) mask * -1 Else TBGL_EntitySetColorMask(%sScene, %eCamera, %TBGL_GREEN ) mask * -1 End If End If If TBGL_GetWindowKeyOnce( hWnd, %VK_R) Then TBGL_EntitySetColorMask(%sScene, %eCamera, %TBGL_DEFAULT) End If If TBGL_GetWindowKeyState( hWnd, %VK_UP ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) zz-0.1 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_DOWN ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) zz+0.1 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_Z ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) yy+0.1 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_A ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) yy-0.1 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_RIGHT ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) xx-0.1 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_LEFT ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) xx+0.1 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) End If TBGL_EntitySetRot(%sScene, %eContour, 0, GetTickCount/40, 0) TBGL_SceneRender(%sScene) TBGL_DrawFrame ' -- ESCAPE key to exit application If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While Wend TBGL_DestroyWindow End Function '================================== Sub CreatePointsList() String src = " ' -- Re-declare types Type Point3D x As Single y As Single z As Single red As Single green As Single blue As Single tu As Single tv As Single End Type dim oVertex(2000000) At #Vertex As Point3D dim N At #total As long 'dim oColorA(2000000) At #ColorA As TBGL_TRGB Long a, b, c, Nb Single x, z, k, xMin, yMin, zMin, xMax, yMax, zMax, range, step1 Long NbX Long NbZ Long NbY nbx = 300 nby = 300 nbz = 300 'xMin = -2 : yMin = -2: zMin = -2 : xMax = 2: yMax = 2 : zMax = 2 'xMin = -3 : yMin = -3: zMin = -3 : xMax = 3: yMax = 3 : zMax = 3 xMin = -4 : yMin = -4: zMin = -4 : xMax = 4: yMax = 4 : zMax = 4 'xMin = -5 : yMin = -5: zMin = -5 : xMax = 5: yMax = 5 : zMax = 5 range = xMax - xMin step1 = range / NbX x = xMin: z = zMin : y = yMin N = 0 For c = 0 To NbY For b=0 To NbZ For a=0 To NbX 'k = 320*(((x*x + (9*y*y)/4 +z*z -1)^3) - x*x*z*z*z - (9*y*y*z*z*z)/80) k = Sin(x*y)+Sin(y*z)+Sin(z*x) 'k = x^3+y^2+z^2 'k = Pow(x,4) + Pow(y,4) + Pow(z,4) - Pow(x*x + y*y + z*z,2) + 3 * (x*x + y*y + z*z) 'k = x^4 + y^4 + z^4 - (x^2 + y^2 + z^2)^2 + 3 * (x^2 + y^2 + z^2) If k <= 0.1 And k >= -0.1 Then 'If k <= 0.5 And k >= -0.5 Then N = N+1 oVertex(N).x = x oVertex(N).y = y oVertex(N).z = z oVertex(N).tu = a/NbX oVertex(N).tv = b/Nbz End If x = x + step1 Next a x = xMin z = z + step1 Next b x = xMin z = zMin y = y + step1 Next c 'print str N terminate " ' -- Pass the source 'O2_Asmo src o2_basic src If Len(o2_error) Then MsgBox 0, o2_error : Stop End If ' -- Execute o2_exec Long N TBGL_NewList %lMyPoints TBGL_PointSize 2 TBGL_UseLighting %FALSE TBGL_BeginPoly %GL_POINTS For N=1 To Nb glTexCoord2f(Vertex(N).tu, Vertex(N).tv) glVertex3f(Vertex(N).x,Vertex(N).y,Vertex(N).z) Next TBGL_EndPoly TBGL_EndList TBGL_UseLighting %TRUE End Sub
Last edited by primo; 13-10-2017 at 08:19.
this demo using a thinbasic without calling Oxygen, it display the progress in the taskbar, the speed depends on several factors
my neighbor said: you want my son to be lazy and not solving the equations by himself but by crawling like a rabbit sniffing if the equation correct here and there or not !! and he suspect that this is not a correct program and producing a fake shapes , but i show him an equation in a trusted site , the mathematica site, here: https://www.wolfram.com/mathematica/...ojections.html
the first graphics show this equation:
k = x^6 - 5* x^4* y* z + 3* x^4* y^2 + 10* x^2* y^3* z + 3* x^2* y^4 - y^5* z + y^6 + z^6 - 1
it produce the same graphics as this program, just uncomment line 159 (note we have moved the +1 from right to left -1)
interestingly thinbasic math '^' is speedier than Pow by two seconds (uncomment line 158 )
don't forget to comment the unused equations
Uses "TBGL" , "Math" #Include Once "%APP_INCLUDEPATH%\thinbasic_gl.inc" #Include Once "%APP_INCLUDEPATH%\thinbasic_glu.inc" BEGIN CONST ' -- Scene IDs %sScene = 1 ' -- Entity IDs %eCamera = 1 %eContour %quat %lMyPoints %texOne END CONST Global x, y, z, xx, yy,zz As Single Global FrameRate, total As Long FUNCTION TBMAIN() Global hWnd As DWord Global FrameRate As Double Global flag As Long flag = 1 ' -- Create and show window hWnd = TBGL_CreateWindowEx("press Space to toggle the camera position , press 'M' to set a mask , 'R' reset mask to default ", 800, 600, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) TBGL_ShowWindow ' -- Create scene TBGL_SceneCreate(%sScene) ' -- Create basic entities ' -- Create camera to look from 0, 5, 15 to 0, 0, 0 TBGL_EntityCreateCamera(%sScene, %eCamera) TBGL_EntitySetPos(%sScene, %eCamera, 0, 5, 15) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) Dim T0 As Double = Timer ' -- Create something to look at CreatePointsList() Dim T1 As Double = Timer MsgBox(0, "Total time to create points List " & Format$(T1 - T0, "#0.00") & " secs" & " ... number of points = " & Str$(total)) TBGL_EntityCreateDLSlot(%sScene, %eContour, 0, %lMyPoints) TBGL_EntitySetColor(%sScene, %eContour, 255, 255, 255) TBGL_EntitySetPos(%sScene, %eContour, 0, 0, 0) ' -- Resets status of all keys TBGL_ResetKeyState() TBGL_EntitySetTexture(%sScene, %eContour, %texOne ) TBGL_LoadTexture APP_Path+"SampleScripts\TBGL\GBuffers\Textures\Bricks.bmp", %texOne, %TBGL_TEX_MIPMAP 'TBGL_LoadTexture APP_Path+"SampleScripts\UI\Dialogs\Images\frogduck.bmp", %texOne, %TBGL_TEX_MIPMAP 'TBGL_LoadTexture APP_SourcePath+"Marble-Wood.bmp", %texOne, %TBGL_TEX_MIPMAP 'TBGL_PolygonLook %GL_LINE ' -- Main loop While TBGL_IsWindow(hWnd) FrameRate = TBGL_GetFrameRate TBGL_SetWindowTitle( hWnd, "FPS = "+Str$(FrameRate)+" use arrow keys and A/Z to navigate the scene") TBGL_ClearFrame If TBGL_GetWindowKeyOnce( hWnd, %VK_SPACE) Then If flag = 1 Then TBGL_EntitySetPos(%sScene, %eCamera, 0, 25, 0.1) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) flag * -1 Else TBGL_EntitySetPos(%sScene, %eCamera, 0, 5, 15) TBGL_EntitySetTargetPos(%sScene, %eCamera, 0, 0, 0) flag * -1 End If End If If TBGL_GetWindowKeyState( hWnd, %VK_UP ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) zz-0.2 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_DOWN ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) zz+0.2 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_Z ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) yy+0.2 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_A ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) yy-0.2 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_RIGHT ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) xx-0.2 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) ElseIf TBGL_GetWindowKeyState( hWnd, %VK_LEFT ) Then TBGL_EntityGetPos( %sScene, %eCamera, xx, yy, zz) xx+0.2 TBGL_EntitySetPos(%sScene, %eCamera, xx, yy, zz) End If TBGL_EntitySetRot(%sScene, %eContour, 90, GetTickCount/40, 0) TBGL_SceneRender(%sScene) TBGL_DrawFrame ' -- ESCAPE key to exit application If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While Wend TBGL_DestroyWindow END FUNCTION ' -- Render procedure '================================== Sub CreatePointsList() Dim zz As Single String plotted Long a, b, c, Nb Single x, z, k, xMin, yMin, zMin, xMax, yMax, zMax, range, step1 Long NbX=150 Long NbZ=150 Long NbY=150 'xMin = -2 : yMin = -2: zMin = -2 : xMax = 2: yMax = 2 : zMax = 2 xMin = -3 : yMin = -3: zMin = -3 : xMax = 3: yMax = 3 : zMax = 3 'xMin = -5 : yMin = -5: zMin = -5 : xMax = 5: yMax = 5 : zMax = 5 'xMin = -1.5 : yMin = -1.5: zMin = -1.5 : xMax = 1.5: yMax = 1.5 : zMax = 1.5 range = xMax - xMin step1 = range / NbX x = xMin: z = zMin : y = yMin TBGL_NewList %lMyPoints TBGL_PointSize 2 TBGL_UseLighting %FALSE TBGL_BeginPoly %GL_POINTS For c = 0 To NbY For b=0 To NbZ For a=0 To NbX 'k = 320*(((x*x + (9*y*y)/4 +z*z -1)^3) - x*x*z*z*z - (9*y*y*z*z*z)/80) 'Heart 'k = Pow(x,4) + Pow(y,4) + Pow(z,4) - Pow(x*x + y*y + z*z,2) + 3 * (x*x + y*y + z*z) 'k = Sin(x*y)+Sin(y*z)+Sin(z*x) k = x^2 + y^2 - z^2 -1 'k = -y +0.7/Log(x^2+z^2)+.6 'dome 'k = Pow(x,6) - 5* Pow(x,4)* y* z + 3* Pow(x,4)* Pow(y,2) + 10* Pow(x,2)* Pow(y,3)* z + 3* Pow(x,2)* Pow(y,4) - Pow(y,5)* z + Pow(y,6) + Pow(z,6) - 1 'k = x^6 - 5* x^4* y* z + 3* x^4* y^2 + 10* x^2* y^3* z + 3* x^2* y^4 - y^5* z + y^6 + z^6 - 1 'k = 4* z^4 + 9*(x^2 + y^2 - 4*z^2)-1 'Eight Solid 'If k <= 0.05 And k >= -0.05 Then 'If k <= 0.01 And k >= -0.01 Then 'If k <= 0.1 And k >= -0.1 Then If k <= 0.2 And k >= -0.2 Then total+1 glTexCoord2f(a/NbX, b/Nbz) 'glColor3f(0,1,0) glVertex3f(x,y,z) End If x + step1 Next a x = xMin z + step1 Next b plotted = Str$(Int((c/nby)*100) )+" % "+" ..... please wait " TBGL_SetWindowTitle( hWnd, plotted) x = xMin z = zMin y + step1 Next c TBGL_EndPoly TBGL_EndList End Sub
Last edited by primo; 14-10-2017 at 12:03.
Great
This is my preferred.
Curves_NoOxygen_Preferred.jpg
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
This is so hypnotic, can't stop viewing it
Just one tip - instead of:
you can do simply:If k <= 0.2 And k >= -0.2 Then
It is not just a syntactic sugar, it can give you a boost in performance as well!If between(k, -0.2, 0.2) Then
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Between !!!!!! certainly it is a syntactic sugar, and speedier than the infinitely complex syntax :
If k <= 0.2 And k >= -0.2 Then.
albiet this function appears very natural, alas no basic language have implemented it before .
also it is including -0.2 and 0.2 in the checking like what is wanted
but what if we want it to express this If k < 0.2 And k > -0.2 Then, i have checked "Inside" it seems to behave like "between"
its output is:Uses "Console" Long i For i=1 To 20 'If Between(i, 7, 14) Then If Inside(i, 7, 14) Then 'If MinMax(i, 7, 14) Then 'If Outside(i, 7, 14) Then Print i PrintL End If Next WaitKey()
7
8
9
10
11
12
13
14
and what comes to my mind is that it should exclude 7, 14.
Thanks Petr for the continuous support
Between and Inside do the same check but result has a different meaning.
Inside is just a check that the expression is inside the limits (limits included).
http://www.thinbasic.com/public/prod...tml?inside.htm
Between does the same check but returns a number between 1 and 100 depending if numeric expression is closer to lower or upper bound.
It was asked and developed with the idea of "distance" and not just true/false
http://www.thinbasic.com/public/prod...ml?between.htm
Some would say RTFM but, as you know, here we do not use that acronym
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
The idea of distance for the between function is great, it reminds me with the idea of distance in Mandelbrot set plotting, will think about that.
this makes me understand the 'between' function and distance idea more:
the output is:Uses "Console" Single i, x i = 7 x = Between(i, 7, 14) PrintL x i = 10.5 x = Between(i, 7, 14) PrintL x i = 14 x = Between(i, 7, 14) PrintL x WaitKey()
1
50
100
Last edited by primo; 17-10-2017 at 14:57.
Bookmarks