Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.