Skip to content

Instantly share code, notes, and snippets.

View daseyb's full-sized avatar

Dario Seyb daseyb

View GitHub Profile
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);
@daseyb
daseyb / offset.cpp
Last active February 13, 2017 20:53
Basic Polygon Offsetting
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
#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;
\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]
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
//_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