homog2d library
Macros | Typedefs | Functions
ttmath_t1.cpp File Reference

This is a test file demonstrating the usage of the ttmath library. More...

#include "../../homog2d.hpp"
Include dependency graph for ttmath_t1.cpp:

Macros

#define HOMOG2D_USE_TTMATH
 

Typedefs

using BigM32 = ttmath::Big< 3, 2 >
 

Functions

int main ()
 

Detailed Description

This is a test file demonstrating the usage of the ttmath library.

See homog2d_manual.md::bignum

Build and run with $ make test-bn

Macro Definition Documentation

◆ HOMOG2D_USE_TTMATH

#define HOMOG2D_USE_TTMATH

Typedef Documentation

◆ BigM32

using BigM32 = ttmath::Big<3,2>

Function Documentation

◆ main()

int main ( )
19 {
21  Point2d_<ttmath::Big<1,2>> p2(10,10);
22  std::cout << "FP size of p1: mantissa=" << p1.dsize().first << ", exponent=" << p1.dsize().second << " bits\n";
23  std::cout << "FP size of p2: mantissa=" << p2.dsize().first << ", exponent=" << p2.dsize().second << " bits\n";
24 
25  auto li = p1*p2; // automatic type conversions between two types with different underlying numerical types
26  std::cout << li << '\n';
27  std::cout << "FP type of line=" << getString(li.dtype()) << '\n';
28  std::cout << "FP size of line: mantissa=" << li.dsize().first << ", exponent=" << li.dsize().second << " bits\n";
29 
30  Segment s0( 0,0,45,45); // uses the default ttmath type
31  Segment_<ttmath::Big<3,1>> s1( -8,5,10,-15); // specific type
32  Segment_<BigM32> s2( 1,2,3,4 ); // this can be easier to read
33  auto it0 = s1.intersects( s2 );
34  auto it = s1.intersects( li );
35  if( it() )
36  std::cout << "Intersection of segment and line: " << it.get() << '\n';
37 
38  std::cout << "FP type of s1=" << getString(s1.dtype()) << '\n';
39  std::cout << "FP size of s0: mantissa=" << s0.dsize( ).first << ", exponent=" << s0.dsize().second << " bits\n";
40  std::cout << "FP size of s1: mantissa=" << s1.dsize( ).first << ", exponent=" << s1.dsize().second << " bits\n";
41 
44 
45  auto it2 = cir.intersects(s1);
46  auto it3 = cir.intersects(li);
47  auto it4 = cir.intersects(rect);
48  auto it5 = li.intersects(rect);
49  auto it6 = s1.intersects(rect);
50 }
A circle.
Definition: homog2d.hpp:378
std::pair< int, int > dsize() const
Get data size expressed as number of bits for, respectively, mantissa and exponent.
Definition: homog2d.hpp:1345
FRect rect
Definition: homog2d_test.cpp:4038
Line2d li
Definition: homog2d_test.cpp:4035
A Flat Rectangle, modeled by its two opposite points.
Definition: homog2d.hpp:379
A line segment, oriented (OSegment_) or not (Segment_). Holds the two points.
Definition: homog2d.hpp:366
detail::Intersect< detail::Inters_2, FPT > intersects(const Line2d_< FPT2 > &li) const
Circle/Line intersection.
Definition: homog2d.hpp:3434
const char * getString(PtStyle t)
Definition: homog2d.hpp:496
Circle cir
Definition: homog2d_test.cpp:4036
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function: