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
/// <summary> | |
/// Check if two rotated rectangles intersect, assuming they are rotated relative to their center points | |
/// </summary> | |
/// <param name="r1">The first rectangle</param> | |
/// <param name="r2">The second rectangle</param> | |
/// <param name="rotation1">The first rectangle's rotation in radians</param> | |
/// <param name="rotation2">The second rectangle's rotation in radians</param> | |
/// <returns>Whether the two rectangles intersect</returns> | |
public static bool RectangleIntersection(Rectangle r1, Rectangle r2, float rotation1, float rotation2) | |
{ |
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
// | |
// Copyright (c) 2019 João Baptista de Paula e Silva. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// |
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 <iostream> | |
#include <cstdint> | |
#include <cassert> | |
#include <vector> | |
// Definitions in powers of two | |
constexpr std::size_t MemBlockExp = 6; | |
// A single memory block to try the algorithm | |
struct Block |
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
template <typename Period2, typename Rep, typename Period> | |
constexpr auto fractional_count(const std::chrono::duration<Rep, Period>& duration) | |
{ | |
return std::chrono::duration<double, Period2>(duration).count(); | |
} | |
template <typename Rep, typename Period> | |
std::ostream& operator<<(std::ostream& out, const std::chrono::duration<Rep, Period>& duration) | |
{ | |
namespace ch = std::chrono; |
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
//---------------------------------------------------------------------------- | |
// context.h | |
//---------------------------------------------------------------------------- | |
// Provides an API for context switching (a primitive form of coroutines) | |
//---------------------------------------------------------------------------- | |
// Copyright 2023 João Baptista de Paula e Silva | |
// | |
// This software is provided 'as-is', without any express or implied | |
// warranty. In no event will the authors be held liable for any damages | |
// arising from the use of this software. |