Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: Re: Complex number library

  1. #1
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23

    Re: Complex number library

    Hi Eros,

    I'm getting things backwards... thank you for the kind welcome and the quick response. I don't know why it has taken me and my students so long to find ThinBasic. We are especially fond of the TBGL module!

    The complex.bi file (with tbasic extension) was attached in the previous post.

    No problem with the execution speed of ThinBasic... we are used to using Python for our OpenGL graphics!

    Cheers... and thanks again!

    Stan

    Quote Originally Posted by Eros Olmi
    Is this the complex library you are using:
    http://www.freebasic.net/forum/viewt...number+library

    If not, let me know where I can find it or just post here sources.

    Also found this:
    http://www.freebasic.net/forum/viewt...number+library

  2. #2

    Re: Complex number library

    I do not think it is that complicated if we have something to start from.
    You don't? The basic functions are easy, but the trigonometric functions aren't.

    I once wrote a class in PowerBASIC to deal with complex numbers:
    http://www.jose.it-berater.org/smffo...p?topic=3191.0

    It is based in ansi C functions found in the GNU Scientific Library ( http://www.gnu.org/software/gsl/ ), distributed under the terms of the GNU General Public License (GPL).

    It also makes heavy use of the math functions of the C runtime library, specially because I could not find code to implement some such finite and isnan with PB.

  3. #3

    Re: Complex number library

    Hello Stan,

    I welcome you here also and can only say good things about thinBasic and the crew here. Petr Schreiber is the master of the TBGL module. I created the Sprite part of it and also some other modules.
    With the SDK's available for thinbasic, everyone can create modules but we also would like to hear where we can help the users.

    Anyway, have a great time with thinbasic and I hope we will see you and your students more oftern posting here.

    Best wishes
    Michael Hartlef

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Complex number library

    Hi Stan,

    welcome to thinBasic!

    On TBGL and graphics side, I think ThinBASIC offers one major advantage over Python due its syntax.
    OpenGL and TBGL graphic code is ideal to be structured using indenting.

    While Python is very restrictive about the indenting, you can do it freely in ThinBASIC, to highlight command nesting.

    This you have to do in Python:
    [code=python]
    glPushMatrix
    glRotatef timer/1000, 0, 1, 0
    glBegin(GL_TRIANGLES)
    glVertex3f (-1, 0, 0)
    glVertex3f ( 1, 0, 0)
    glVertex3f ( 0, 1, 0)
    glEnd
    glPopMatrix
    [/code]

    while in ThinBASIC you can indent as necessary, adding more code clarity:
    [code=thinBasic]
    glPushMatrix
    glRotatef timer/1000, 0, 1, 0
    glBegin(GL_TRIANGLES)
    glVertex3f( -1, 0, 0)
    glVertex3f( 1, 0, 0)
    glVertex3f( 0, 1, 0)
    glEnd
    glPopMatrix
    [/code]

    When using TBGL, you can forget about the "3f" and use the built in commands:
    [code=thinbasic]
    tbgl_PushMatrix
    tbgl_Rotate timer/1000, 0, 1, 0
    tbgl_BeginPoly(%GL_TRIANGLES)
    tbgl_Vertex (-1, 0, 0)
    tbgl_Vertex ( 1, 0, 0)
    tbgl_Vertex ( 0, 1, 0)
    tbgl_EndPoly
    tbgl_PopMatrix
    [/code]

    TBGL offers many more high level functions, let me know if you need to know anything about the module.
    Even the very simple above usually provide some enhacement, like being polymorph:
    • TBGL_Vertex can take 2 or 3 parameters, no need for special function like in OpenGL (glVertex2f vs. glVertex3f)
    • TBGL_Rotate can take just one parameter to behave like default 2D rotation
    • TBGL_Translate again polymorph with 2 or 3 params...

    Then there is easy rendering mode setup -> default 3D or custom coordinate system 2D, both with user defined viewports which can be specified using relative coordinates which are more robust than default OpenGL pixels.

    Display lists and textures are fully garbage collected.

    As Mike said, he coded fantastic sprite engine for TBGL, so there is really lot to explore and use.
    Then there are some auxiliary functions, to draw line on screen using one line of code and others.

    You can use TBGL window embedded to normal dialog window, ideal for editor type applications.

    Of course, TBGL can be freely intermixed with native OpenGL code, so you can continue coding the way you are used from Python.

    I hope you will like it!


    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

  5. #5
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23

    Re: Complex number library

    Hi Michael and Petr,

    Thanks for the responses... I do appreciate your kindness!

    Currently I'm in the midst of exploring the sample programs, but I must say that I'm very impressed with ThinBasic. I agree with Petr about Python syntax, particularly the indentation restrictions. I can't tell you how many times we've had issues with Python code and the only thing wrong was the level of indentation... such an annoyance!

    Cheers,

    Stan

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Complex number library

    Quote Originally Posted by José Roca
    I do not think it is that complicated if we have something to start from.
    You don't? The basic functions are easy, but the trigonometric functions aren't.

    I once wrote a class in PowerBASIC to deal with complex numbers:
    http://www.jose.it-berater.org/smffo...p?topic=3191.0

    It is based in ansi C functions found in the GNU Scientific Library ( http://www.gnu.org/software/gsl/ ), distributed under the terms of the GNU General Public License (GPL).

    It also makes heavy use of the math functions of the C runtime library, specially because I could not find code to implement some such finite and isnan with PB.

    I didn't say I would have developed it.
    I said: "I do not think it is that complicated if we have something to start from"

    And now, thanks to you, we have something to start from. And it is even professionally developed (as usual is your code)

    I suppose that if I develop a dedicated module and publish it as source code into thinBasic SVN server (so everyone can get it) I will not infringe any Licence.

    I will see what I can do and than publish in next days into SVN server
    So, Stan, expect something very soon, let say by next week

    Ciao
    Eros
    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

  7. #7

    Re: Complex number library

    Quote Originally Posted by sblank
    Hi Michael and Petr,

    Thanks for the responses... I do appreciate your kindness!

    Currently I'm in the midst of exploring the sample programs, but I must say that I'm very impressed with ThinBasic. I agree with Petr about Python syntax, particularly the indentation restrictions. I can't tell you how many times we've had issues with Python code and the only thing wrong was the level of indentation... such an annoyance!

    Cheers,

    Stan
    I am feeling with you. I wrote once an export script from Blender to TBGL's own model format called M15 in Python. I remember that it was also important that I displayed whitespace charcters as Python also see it differently when one line uses tabs and the other one uses spaces at the front. Even they are lined up the same, for Python it is something different.

    Michael

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Complex number library

    Stan,

    I think I've already something to test.

    Be sure you have installed latest thinBasic beta version 1.7.10.2. You can get from here

    Than get attached files.
    Put "thinBasic_iComplex.dll" (new thinBasic module handling tComplex numbers) into \thinBasic\Lib\ directory
    Use "iComplex_Test.tbasic" script to test them.

    For the moment I've just developed the folllowing:
    • variable declaration using predefined type tComplex
    • function i = iComplex.Set(i1, i2)
    • function i = iComplex.Add(i1, i2)
    • function i = iComplex.Sub(i1, i2)
    • function i = iComplex.Mul(i1, i2)
    • function i = iComplex.TanH(i)


    where i, i1, i2 are variables of tComplex type

    tComplex is defined as follows:
    [code=thinbasic]Type tComplex
    x As Double '---real part
    y As Double '---imaginary part
    End Type[/code]

    Before I will go too much deeper, let me know if I'm on the right track.
    Eros

    PS: attached file removed because surpassed.
    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

  9. #9
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Complex number library

    Won't a 2D library also be necessary to output fractals?
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  10. #10
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23

    Re: Complex number library

    Eros,

    Thank you very much! I'll download the new dll and try it now.

    Also, to answer Kent (hopefully), we should be able to use TBGL to plot fractals. The complex number mathematics are used to calculate escape time... the eventual distance of the iterated complex function from the origin. This distance is a real number. The plotting is done using simple x,y Cartesian coordinates based on this distance of the iterated complex number to the origin. Of course, this isn't a good explanation of fractals, but basically we can plot using standard OpenGL plotting commands.

    In terms of which complex functions we've used in class, the "complex.tbasic" file I attached earlier contains the functions we used most often... and it looks like you have an excellent start here!

    Basically, we use:

    abs (determines distance of complex number to origin)
    power (^)
    add
    subtract
    multiply
    divide
    sin
    cos
    exp

    and would be thrilled with this set and anything else you can add to the module!

    Thanks... and I'll give you some feedback as soon as possible!

    Stan


Page 1 of 3 123 LastLast

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •