Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / New 2D/3D-Math Lib

Author
Message
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 26th Aug 2016 23:57 Edited at: 31st Mar 2023 20:08
Because AppGameKit is not particularly equipped with 3D mathematics. I have implemented a couple of functions from the c ++ library glm to AGK.

A small feature have these functions.
Functions, which have in the beginning a result parameter, return this value as well.

For Example:
Note: This example serves no purpose.



You can theoretically write instead...


Here is the list of functions at a glance:
Types:


Vec2 functions:


Vec3 functions:


Vec4 functions:


Mat4 functions:


If you miss some important functions then say it me.


Have fun and comments are welcome.


MadBit.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)

Donations are always welcome.

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Aug 2016 08:40 Edited at: 27th Aug 2016 08:57
Quote: "Vec3Mul(v2, Vec3Normalize(v0, Vec3Mul(v0, v0, v2)), Vec3Normalize(v1, Vec3Mul(v1, v1, v2)))"

this will not work if the functions have no return value.
i think its better to have the return value as normal output not as by ref.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 27th Aug 2016 10:44 Edited at: 27th Aug 2016 10:44
Thank you
I think you forgot Mat4Mul(result Ref As Mat4, m1 As Mat4, m2 As Mat4)

Using AGKv2 Tier1
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Aug 2016 22:05
I wrote a vector library years ago that might be of use to you.

https://forum.thegamecreators.com/thread/192569

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 29th Aug 2016 11:43 Edited at: 29th Aug 2016 19:15
janbo wrote: "I think you forgot Mat4Mul(result Ref As Mat4, m1 As Mat4, m2 As Mat4)"

Ohh, I've completely overlooked. That is the most important function. I have re-uploaded (with supplemented function). Thank you.

Markus wrote: "this will not work if the functions have no return value.
i think its better to have the return value as normal output not as by ref."

Are you sure? Here I show the complete definition of the function. If I have done right, it should store the result in the reference variable and as a return-value of the function.

EDIT: Sorry. I have forgotten the code.


My strengthen lie more in C / C ++ not in Basic. It could sneak in a few mistakes.

Phaelax wrote: "I wrote a vector library years ago that might be of use to you."

Thank you. I will look at it. Maybe I can add my library something.
Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Aug 2016 07:37
Quote: "Here I show the complete definition of the function"

ah ok, that is better
i would like to see that agk provide all this much commands without the id system at vectors.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
MadBit
VIP Member
Gold Codemaster
14
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 30th Aug 2016 08:16

Markus wrote: "i would like to see that agk provide all this much commands without the id system at vectors."


Yes, I agree. This ID system has their advantages and disadvantages. But at vector and matrices calculations, I find it pointlessly (my opinion).
It would be better to handle vectors matrices as intrinsically datatypes. But I think the effort would be too big for Paul.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)
Pixie-Particle-Engine
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 31st Aug 2016 10:18
Unless they add a Vector data type, you'd have to keep the ID system. Otherwise, how would you return anything beyond a scalar value?

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Aug 2016 22:52 Edited at: 31st Aug 2016 22:53
@Phaelax
Quote: "Unless they add a Vector data type, you'd have to keep the ID system"

if basic can use any Type and the compiler understand it
why can't the language itself, that is what make me confuse.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-04-26 05:32:56
Your offset time is: 2024-04-26 05:32:56