ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
geometry.h File Reference

Common geometry types. More...

#include <algorithm>
#include <cmath>
#include <concepts>
#include <cstddef>
#include <optional>
#include <type_traits>
#include <vector>
Include dependency graph for geometry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  asw::Vec2< T >
 A 2D vector in space. More...
 
class  asw::Vec3< T >
 A 3D vector in space. More...
 
class  asw::Quad< T >
 A 2D rectangle in space. More...
 

Namespaces

namespace  asw
 
namespace  asw::geometry
 

Typedefs

using asw::Vec2f = Vec2<float>
 Type aliases for common vector and rectangle types.
 
using asw::Vec2i = Vec2<int>
 
using asw::Vec3f = Vec3<float>
 
using asw::Vec3i = Vec3<int>
 
using asw::Quadf = Quad<float>
 
using asw::Quadi = Quad<int>
 
template<typename T >
using asw::Polygon = std::vector<Vec2<T>>
 A polygon, as its corners in order. The last corner joins the first.
 
using asw::Polygonf = Polygon<float>
 

Functions

template<typename T >
Vec2< T >::Real asw::geometry::signed_area (const Polygon< T > &polygon)
 Get the signed area of a polygon.
 
template<typename T >
Quad< T > asw::geometry::bounds (const Polygon< T > &polygon)
 Get the smallest rectangle that holds every corner of a polygon.
 
template<typename T >
bool asw::geometry::point_in_triangle (const Vec2< T > &point, const Vec2< T > &a, const Vec2< T > &b, const Vec2< T > &c)
 Check if a point is inside a triangle. Points on an edge are inside.
 
std::optional< float > asw::geometry::ray_hit (const Vec2f &origin, const Vec2f &direction, const Vec2f &a, const Vec2f &b)
 Find where a ray hits a line segment.
 
Polygonf asw::geometry::visibility (const Vec2f &from, float radius, const std::vector< Polygonf > &occluders, float direction=0.0F, float cone=0.0F)
 Find the area that can be seen from a point.
 
void asw::geometry::visibility (Polygonf &result, const Vec2f &from, float radius, const std::vector< Polygonf > &occluders, float direction=0.0F, float cone=0.0F)
 Find the area that can be seen from a point, into a polygon you keep between calls so it does not allocate each time.
 
void asw::geometry::visibility (Polygonf &result, const Vec2f &from, float radius, const std::vector< Polygonf > &occluders, const std::vector< Quadf > &occluder_bounds, float direction=0.0F, float cone=0.0F)
 Find the area that can be seen from a point, with the bounds of the occluders already worked out, e.g. once per frame for many lights.
 

Detailed Description

Common geometry types.

Author
Allan Legemaate (alege.nosp@m.maat.nosp@m.e@gma.nosp@m.il.c.nosp@m.om)
Date
2025-03-26

Definition in file geometry.h.