Skip to content

Instantly share code, notes, and snippets.

View Erkaman's full-sized avatar

Eric Arnebäck Erkaman

View GitHub Profile
/*
The MIT License (MIT)
Copyright (c) 2017 Eric Arnebäck
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:
The above copyright notice and this permission notice shall be included in
/*
The MIT License (MIT)
Copyright (c) 2017 Eric Arnebäck
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
/*
The MIT License (MIT)
Copyright (c) 2017 Eric Arnebäck
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:
The above copyright notice and this permission notice shall be included in
@Erkaman
Erkaman / shoelace.cpp
Last active October 29, 2017 17:42
Accompanying source code for my article: https://erkaman.github.io/posts/area_convex_polygon.html
/*
This software is released under the MIT license:
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 software is released under the MIT license:
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:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
/*
The MIT License (MIT)
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:
@Erkaman
Erkaman / broken.cpp
Created November 14, 2017 18:47
Program that results in "An internal error has occurred in the compiler" for VC++ in VS 15.4.4
class Foo{};
int main(){
Foo foos[1] = { Foo()};
auto lambdaFunctionThatDoesNothing = [foos]() { };
}
@Erkaman
Erkaman / partition_of_unity.cpp
Last active April 22, 2018 11:02
Program that provides empirical evidence that the clamped cosine lobes 0.5cos^2 and (5/6)cos^4 form a partition of unity over the unit sphere. This is related to the ambient dice paper: http://www.ppsloan.org/publications/AmbientDice.pdf
#include <stdio.h>
#include <math.h>
float max(float x, float y) {
return x > y ? x : y;
}
class vec3 {
public:
float x;
/*
The MIT License (MIT)
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:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
@Erkaman
Erkaman / kmeans_color_quantization.cpp
Last active January 29, 2018 09:14
This program implements color quantization with K-means clustering using Lloyd's algorithm
/*
The MIT License (MIT)
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: