| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- //
- // shape.hpp
- // math
- //
- // Created by Sam Jaffe on 7/5/16.
- //
- #pragma once
- #include "vector/vector.hpp"
- #include "math_fwd.hpp"
- namespace math { namespace dim2 {
- using point = vec2;
- struct line {
- float length() const;
- float slope() const;
- point first, second;
- };
- struct circle {
- point center;
- float radius;
- };
- struct triangle {
- point a, b, c;
- };
- struct quad {
- point ll, lr, ur, ul;
- };
- struct rectangle {
- operator quad() const;
- point origin, size;
- };
- struct square {
- operator rectangle() const;
- operator quad() const;
- point origin;
- float size;
- };
- }}
- namespace math { namespace shapes {
- std::vector<dim2::line> segments(dim2::quad const & shape);
- }}
- namespace math { namespace lines {
- bool parallel(dim2::line const & lhs, dim2::line const & rhs);
- dim2::point intersection(dim2::line const & lhs, dim2::line const & rhs);
- dim2::line orthogonal(dim2::line const & from, dim2::point const & to);
- }}
|