Results 1 to 10 of 15

Thread: cVec thinBasic math vector class

Hybrid View

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

    cVec thinBasic math vector class

    I made a math vector class for thinBasic. It is focused on ease of use rather than efficiency. I based a lot of the methods of the class from the Processing language, hope that it might bring more users to thinBasic. Because of name conflicts in thinBasic I had to change my method names, but the functional use is there. You can download a zip from github here:

    https://github.com/kryton9/thinBasic-cVec

    cVec.tbasicu is the include file needed to use this class.

    cVecUnitTests.tbasic is a complete unit test of this class. A good way to see the use of all the methods.
    testcVecOutMethod.tbasic is a test focused more in depth on the out method of the class.

    all tests green thanks to Primo
    cVecTests.jpg

    You don't need Git to use these files. Just follow the link and click on the following to download a zip file of all the needed code:
    Click image for larger version.
    gitUse.jpg
    Last edited by kryton9; 10-05-2017 at 12:27.
    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

  2. #2
    Quote Originally Posted by kryton9 View Post
    Because of name conflicts in thinBasic I had to change my method names, but the functional use is there.
    Thanks, that is awesome. But why would there be a name conflict. These are methods of a class. Not functions.

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Thanks a lot for using GitHub.
    This improve thinBasic visibility.



    Do you know ... #INCLUDE also works loading data directly from a web page.
    If in GitHub you go into your source code file https://github.com/kryton9/thinBasic...r/cVec.tbasicu and click on raw, you will get direct file link and you can use into a script.
    Of course you need to be connected on internet.

    Example:

    Uses "Console"
    #INCLUDE "https://raw.githubusercontent.com/kryton9/thinBasic-cVec/master/cVec.tbasicu" 
    
    
    ' a 3d vector
    Dim t As cVec 10.12345678, 23.12345678, 5.12345678 
    PrintL "Testing out function for 3d vectors"
    t.out   ' no parameters prints default 2 decimals, x and y and z 
    t.out 1 ' prints 1 decimal,  x and y and z
    t.out 2 ' prints 2 decimals, x and y and z
    t.out 3 ' prints 3 decimals, x and y and z
    t.out 4 ' prints 4 decimals, x and y and z
    t.out 5 ' prints 5 decimals, x and y and z 
    PrintL
    PrintL
    
    
    ' a 2d vector
    Dim p As cVec 2.12345678, 12.12345678 
    PrintL "Testing out function for 2d vectors"
    p.out   ' no parameters prints default 2 decimals, x and y
    p.out 1 ' prints 1 decimal,  x and y
    p.out 2 ' prints 2 decimals, x and y
    p.out 3 ' prints 3 decimals, x and y
    p.out 4 ' prints 4 decimals, x and y
    p.out 5 ' prints 5 decimals, x and y
    PrintL
    
    
    
    
    PrintL "Press a key to end program"
    WaitKey
    
    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

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404
    @Eros I had no idea, that is really cool to be able to do that. I will update my code, so it will be there as an option commented out.

    @Michael That is what I thought, but I was getting errors with name conflicts with keywords.
    Last edited by kryton9; 10-05-2017 at 12:28.
    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

  5. #5
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404
    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

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

    thanks a lot for this contribution!

    I run into odd thingy - when I clone your repository, all files are immediately marked as changed.
    Did you perform any specific setup of git on your PC by any chance?

    Steps to replicate:
    git clone https://github.com/kryton9/thinBasic-cVec.git
    git status
    

    Petr
    Last edited by Petr Schreiber; 11-05-2017 at 19:06.
    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

Similar Threads

  1. is this example destinated for a class for converting into thinbasic?
    By largo_winch in forum Modules specific issues
    Replies: 4
    Last Post: 05-02-2013, 19:43
  2. 3D Vector Math include file.
    By D.J.Peters in forum Math scripts
    Replies: 5
    Last Post: 11-03-2010, 08:02
  3. OpenCL: Vector Add [Updated Sep 04 2011]
    By Petr Schreiber in forum OpenCL
    Replies: 14
    Last Post: 09-02-2010, 10:33
  4. Vector Graphics
    By Pipes in forum TBGL General
    Replies: 21
    Last Post: 31-08-2009, 20:44
  5. Example: passing vector or array to same function
    By e90712 in forum Math scripts
    Replies: 2
    Last Post: 19-07-2008, 00:33

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
  •