Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trigonemetry/Geometry Library - Collision, Perimeter, Etc...
#1
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 Tongue

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) Tongue


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
Reply
#2
Quote:Trigonemetry
[...]
Magnetude


Ever heard of a dictionary?

and did you ask Dr_D and Rel if you could use their code?
Reply
#3
Quote:
Quote:Trigonemetry
[...]
Magnetude
Ever heard of a dictionary?
You know the library's called Geometry lib... But I just didn't care to put a nice 100% correct title to the thread. Also, I realize it's magnitude now...Fixing Tongue

Quote:and did you ask Dr_D and Rel if you could use their code?
I did ask because Rel was the one taking me through any problems I had. The collision routine itself isn't *amazingly* different from the method Rel and Dr D used, but the pre-routine put together with the routine is what makes it so unsimilar Tongue

I took their code and learned each and every function, transferred it to the Geo Math Lib stuff, then finally decided to put it all together in one routine for the lib.

Differences between my collision program and theirs:

Quote:- I support Segmented Data, theirs was vector to vector data.
- I support seperated lines (barriers that are in no way connected to other barriers).
- Mine seems *slightly* faster
- Mine *can* be done just with a call to one function
- It's not their code, but I thought I should give them credit because I did learn from it.

Thanks for complaining Tongue Made me think a bit.
Reply
#4
That's what I wrote my code for. I wanted people to learn from it. Good work!
Reply
#5
Typo problem with magnitude fixed. Thanks for complaining KiZ. I see you read the first post.

Quote:That's what I wrote my code for. I wanted people to learn from it. Good work!
Thanks! If you tested it out and saw the source code you'd notice quite a few differneces (as posted above), which should note that I *did* learn from it. Very much indeed!

EDIT: Updated. Library now comes with 3-d examples.
Reply
#6
Quote:Typo problem with magnitude fixed. Thanks for complaining KiZ. I see you read the first post.

Glad I could help out. ;)
Reply
#7
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.
Reply
#8
Sorry for all the posts, but the lib was considered by me to be complete a while back. Until I have a todo list and work to do that doesn't just poof out of thin air, I don't have much of a choice . . . Tongue

Update:

Outsources.bas now contains code written by other people! Geo Math Lib is accepting functions from *you* now! They will be put in outsources.bas and you will be given full credit.

If you have any ideas/requests let me know. Tongue

Added:

Zamaster's Triangle Collision Functions. If I have time (which I do), I'll be porting them to check with objects and return normals through the collision type, so you can rebound off of the lines.

Although important, I'm not sure if I'll be porting this one to 3D for a while. I have to think about a couple things first Tongue

Changed:

For some reason I was a complete retard and a lot of my stuff used 1 instead of -1. This of course was a problem and was changed.

Updated Link In First Post.
Reply
#9
Added documentation. Also, function overloading now present. I had previously thought ANY was casting the types for me (for whatever reason . . .)

^_^;; Well have fun. Most of the 1D functions will now accept/return all integers/singles/doubles now. I still recommend looking at the .bi's for a little help.

>_> Not the best documentation ever to be honest.

Download (Source + Lib - 50kb), .rar: Geo Math Lib
Reply
#10
great job!!!

BTW, love your new avatar!
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)