Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Xiaohu

Pages: [1]
1
SFML projects / SFML Maths & Iterators utility
« on: October 28, 2019, 01:20:36 am »
[Update] Github link: https://github.com/Eren121/SFML-Math
Previous download link https://www.dropbox.com/s/tp0w90qd1mj0ul1/SFMLMath.zip?dl=0

Hello all!
To debug and avoid repeated stuff, Ii coded a tiny header only lib in C++11.
It add basic math stuff and printable Vectors and Color of the form (X, Y [, Z] ) or (R, G, B, A) to debug better :)

And Vectors/Colors are now... iterables!

Sample :

#include <SFML/Math.h>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    sf::Vector3f myVec3(1, 1, 0);
    sf::Vector2f myVec2(1, 1);

    cout << myVec2 << endl;
    cout << length(myVec2) << ", " << length(myVec3) << endl;
    cout << length2(myVec2) << endl;
    cout << distance({1, 2}, myVec2) << endl;
    cout << dot(myVec3, {0, 0, 1}) << endl;

    for(float & f : myVec2) {
        f += 1;
    }

    cout << myVec2 << endl;

    return 0;
}
 

Output :

Code: [Select]
(1, 1)
1.41421, 1.41421
2
1
0
(2, 2)



If you have any suggestion ^^

Pages: [1]
anything