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
//_pos is in pixel coordinates in a quad | |
float2 offsetFunc(float2 _pos) | |
{ | |
//distance from the center (the quad is (radius + width) * 2 pixels wide) | |
_pos -= radius + width; | |
_pos /= scale; | |
float x = length(_pos); | |
//function, made in GeoGebra: http://imgur.com/zMbqAcs |
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
private void CheckMapCollisionUp(float _dt) | |
{ | |
//Extends of the player in worl coordinates | |
//Stretched by velocity to prevent tunneling | |
float bottom = gameObject.collider.AABB.Bottom / 2 + (vel.Y < 0 ? -vel.Y * _dt : 0); | |
float top = gameObject.collider.AABB.Top / 2 + (vel.Y > 0 ? -vel.Y * _dt : 0); | |
float left = gameObject.collider.AABB.Left / 2 + (vel.X > 0 ? -vel.X * _dt : 0); | |
float right = gameObject.collider.AABB.Right / 2 + (vel.X < 0 ? -vel.X * _dt : 0); | |
//Tiles around the player vertically, with some leeway |
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
\begin{figure}[htb!] | |
\begin{centering} | |
\begin{tikzpicture} | |
\begin{polaraxis}[xmin=0,xmax=180,ymax=1, | |
ytick align=outside, | |
yticklabel style={ | |
anchor=north, | |
yshift=-2*\pgfkeysvalueof{/pgfplots/major tick length} | |
}] | |
\addplot+[mark=f,domain=0:180,samples=600] |
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 <vector> | |
#include <set> | |
#include <list> | |
int count_pagefaults(std::vector<int> access, int max_size) { | |
std::set<int> working_set; | |
std::list<int> lru_queue; | |
int page_faults = 0; |
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
Vec2d orthogonal(Vec2d val) { | |
return {-val.y, val.x}; | |
} | |
Vec2d calculateBisector(Vec2d prev, Vec2d curr, Vec2d next) { | |
auto nextDir = (next - curr).normalized(); | |
auto prevDir = (prev - curr).normalized(); | |
Vec3d bisector = (nextDir + prevDir); | |
Vec2d norm = orthogonal(nextDir); | |
// If prev, curr and next are colinear |
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
using UnityEngine; | |
using System.Collections; | |
public class Mirror : MonoBehaviour | |
{ | |
public Vector3 ReflectPosition(Transform originalObject) | |
{ | |
Vector3 localOriginal = transform.InverseTransformPoint(originalObject.position); | |
Vector3 localReflected = Vector3.Reflect(localOriginal, Vector3.forward); |