Created
January 31, 2019 17:23
-
-
Save Const-me/c2664ba2f79f17f5d68a08454265fe8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include <SimpleMath.h> | |
using DirectX::SimpleMath::Vector2; | |
#include <Mathematics/GteIntrSegment2Segment2.h> | |
inline gte::Vector2<float> _gte( const Vector2& dx ) | |
{ | |
return gte::Vector2<float>{ dx.x, dx.y }; | |
} | |
inline gte::Segment2<float> gteSegment( const Vector2& p1, const Vector2& p2 ) | |
{ | |
return gte::Segment2<float>{ _gte( p1 ), _gte( p2 ) }; | |
} | |
int main() | |
{ | |
/* | |
Segments: | |
[ 1.87500000, -2.50000000 ] DirectX::SimpleMath::Vector2 | |
[ 1.75000000, -2.50000000 ] DirectX::SimpleMath::Vector2 | |
[ 2.50000000, -2.50000000 ] DirectX::SimpleMath::Vector2 | |
[ 2.00000000, -2.50000000 ] DirectX::SimpleMath::Vector2 | |
*/ | |
auto s1 = gteSegment( { 1.87500000, -2.50000000 }, { 1.75000000, -2.50000000 } ); | |
auto s2 = gteSegment( { 2.50000000, -2.50000000 }, { 2.00000000, -2.50000000 } ); | |
using TSegment = gte::Segment2<float>; | |
gte::TIQuery<float, TSegment, TSegment> query; | |
const bool res = query( s1, s2 ).intersect; | |
// This prints true, while even their bounding boxes do not intersect :-( | |
printf( "%s\n", res ? "true" : "false" ); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment