freebasic.net Forum Index
FreeBASIC's Official Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in

Trigonemetry/Geometry Library - Collision, Perimeter, Etc...
Goto page 1, 2  Next
 
Post new topic   Reply to topic    freebasic.net Forum Index -> Projects
View previous topic :: View next topic  
Author Message
Pritchard
Guru
PostPosted: Jun 08, 2006 19:10    Post subject: Trigonemetry/Geometry Library - Collision, Perimeter, Etc... Reply with quote

Thanks to Relsoft, Dr. D, and me putting myself in Geometry, I am able to release this library. Relsoft and Dr. D deserve all credit for teaching me collision detection :P

This library's uses pretty darn fast methods. The 2D physics AND Collision.bas goes around 7000 frames per second here.


Download (Source + Lib - 50kb), .rar: Geo Math Lib

Note: Was compiled under Windows XP. If you have trouble with it and it's not a lower than .16 issue, try compiling it yourself.


The Lib Supports the Following:

  • Tested on Version .16 Unstable, so no guarantees for you .15'ers
  • 1D, 2D, and 3D Trigonometric Functions with Single Digit Precision
  • Spherical Against Line Segment Collision Detection for All Dimensions Supported:
    Code:
    Collision_Detection_Dimension(Boundary Type, Boundary Start, Boundary End, Object Position, Radius)
    Boundary Type is the value of which normal to use.
  • Spherical Against Spherical Collision
  • A ton of other stuff, really (function list below) :P



Type List:

  • Geo_Vector
  • Geo_Segment
  • Geo_Collision_Type
  • Enum: Geo_Option



Function List:

  • Segment_Collision
  • Object_Collision
  • Triangle_Collision
  • Closest_Point_On_Line
  • Get_Angle
  • Get_Cos_Angle
  • Get_Distance
  • Get_Dot_Product
  • Get_Endpoint
  • Get_Magnitude
  • Get_MidPoint
  • Get_Triangle_Perimeter
  • Normalize_Vector
  • Vector_Normal 'Normal between two vectors


So what are you waiting for? Test and complain to me about it people:

Download (Source + Lib - 50kb), .rar: Geo Math Lib


Last edited by Pritchard on Jul 26, 2006 17:57; edited 17 times in total
 
Back to top
View user's profile Send e-mail
voodooattack
Sr. Member
PostPosted: Jun 08, 2006 20:05    Post subject: Reply with quote

works amazingly well here! :)

and i'm using .15, just a "fbc Geo_Math_Lib.bas -lib" and it's done ;D

i wish i could use that within Nano :P (evil laugh!! MUAHAHAHAHA!!) >:P

i must say i'm impressed.. especially with that GetAngle proc ;)
 
Back to top
View user's profile Visit poster's website MSN Messenger
Deleter
Master
PostPosted: Jun 08, 2006 23:23    Post subject: Reply with quote

voodooattack wrote:
works amazingly well here! :)

and i'm using .15, just a "fbc Geo_Math_Lib.bas -lib" and it's done ;D

i wish i could use that within Nano :P (evil laugh!! MUAHAHAHAHA!!) >:P

i must say i'm impressed.. especially with that GetAngle proc ;)

Well if you add an extension to every function I think you could use it in nano. :P
 
Back to top
View user's profile
voodooattack
Sr. Member
PostPosted: Jun 09, 2006 0:00    Post subject: Reply with quote

Deleter wrote:
Well if you add an extension to every function I think you could use it in nano. :P


*goes to prepare his artillery* >:D
 
Back to top
View user's profile Visit poster's website MSN Messenger
relsoft
Master
PostPosted: Jun 09, 2006 0:54    Post subject: Reply with quote

Now finish that party game. :*)
 
Back to top
View user's profile Visit poster's website Yahoo Messenger
Pritchard
Guru
PostPosted: Jun 09, 2006 5:26    Post subject: Reply with quote

relsoft wrote:
Now finish that party game. :*)
Shhh!!!! :P
 
Back to top
View user's profile Send e-mail
1000101
Hero
PostPosted: Jun 09, 2006 5:42    Post subject: Reply with quote

By the way, it's Magnitude.

http://dictionary.reference.com/search?q=magnitude
 
Back to top
View user's profile
Pritchard
Guru
PostPosted: Jun 09, 2006 5:48    Post subject: Reply with quote

1000101 wrote:
By the way, it's Magnitude.

http://dictionary.reference.com/search?q=magnitude

EDIT: Fixed. Thanks for reading the first post, and complaining to me.

Double Edit: Added 3-D examples, not finished. I have to learn 3D first...
 
Back to top
View user's profile Send e-mail
Zamaster
Master
PostPosted: Jun 09, 2006 12:44    Post subject: Reply with quote

how bout we use it in ATTO.... atto anyone? atto please? I WANT ATTO!!!!
 
Back to top
View user's profile Send e-mail AIM Address
Pritchard
Guru
PostPosted: Jun 10, 2006 13:46    Post subject: Reply with quote

Update:

Finally! I have just added Object to Object (Circle to Circle) collision. Updated link in first post.

Changed:

Collision_Detection_2D is now Called: Segment_Collision

Object to Object Collision is called: Object_Collision_2D (only 2D is available)

New Option Added for Object_Collision - First parameter is an Enum. Either Geo_Physics or Geo_No_Physics. Geo_No_Physics won't return the normals, so it's slightly faster.
 
Back to top
View user's profile Send e-mail
1000101
Hero
PostPosted: Jun 10, 2006 14:52    Post subject: Reply with quote

Zamaster wrote:
how bout we use it in ATTO.... atto anyone? atto please? I WANT ATTO!!!!


I had already planned to use line-collision detection in atto. The ships will have a line-loop describing the outside edges and if weapons fire crosses one of said lines, then a hit will be scored.
 
Back to top
View user's profile
Pritchard
Guru
PostPosted: Jun 10, 2006 14:56    Post subject: Reply with quote

1000101 wrote:
I had already planned to use line-collision detection in atto. The ships will have a line-loop describing the outside edges and if weapons fire crosses one of said lines, then a hit will be scored.
Hahah. Add this line to the Object_Collision_2D, then compile and run Object_Collision.bas in the Two Dimensional examples folder:

Code:
Line (c.x, c.y)-(d.x, d.y)
You get a line outside of the red ball reflecting the white one :P
 
Back to top
View user's profile Send e-mail
1000101
Hero
PostPosted: Jun 10, 2006 15:40    Post subject: Reply with quote

It's an interesting bit of a math lib, I'll have to take a look at it a bit more. However, we're not that far yet. We're still working on code even before that happens. Once we have something too collide, then we'll worry about checking for that :D
 
Back to top
View user's profile
elcalen

PostPosted: Jun 11, 2006 13:33    Post subject: Reply with quote

Type Geo_Segment_1D is dublicated in the .bi file. Gave me an error when I tried to compile it...

Also you have this line in the examples: #include "Fbgfx.bi". You should use "fbgfx.bi" for it to compile in Linux. Linux is case sensitive!

I've only tried one or two examples, but looks good so far. Thanks, mate.
 
Back to top
View user's profile Visit poster's website
Pritchard
Guru
PostPosted: Jun 11, 2006 13:58    Post subject: Reply with quote

elcalen wrote:
Type Geo_Segment_1D is dublicated in the .bi file. Gave me an error when I tried to compile it...

Also you have this line in the examples: #include "Fbgfx.bi". You should use "fbgfx.bi" for it to compile in Linux. Linux is case sensitive!

I've only tried one or two examples, but looks good so far. Thanks, mate.
Thanks for the complements and complaints! Geo_Segment_1D is duplicated because I added it at the last minute. I only had it for one dimension because I never used it, so I forgot all about it.

Case sensitivity is important. I'll have to remember that! Be right back in a minute with the update!

EDIT: Fixed, updated in first post.
 
Back to top
View user's profile Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    freebasic.net Forum Index -> Projects All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



sf.net phatcode