Results 1 to 10 of 15

Thread: cVec thinBasic math vector class

Share/Bookmark

Hybrid View

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

    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
    Click image for larger version. 

Name:	cVecTests.jpg 
Views:	18 
Size:	93.9 KB 
ID:	9692

    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.
    Click image for larger version. 

Name:	gitUse.jpg 
Views:	18 
Size:	43.8 KB 
ID:	9689
    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
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    51
    Posts
    3,259
    Blog Entries
    2
    Rep Power
    336
    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.
    Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200.

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,113
    Blog Entries
    2
    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/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    61
    Posts
    3,869
    Rep Power
    397
    @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
    61
    Posts
    3,869
    Rep Power
    397
    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
    6,776
    Blog Entries
    3
    Rep Power
    690
    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 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

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

Posting Permissions

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