Skip to content

Instantly share code, notes, and snippets.

@yakir12
yakir12 / Question.m
Created July 28, 2015 04:31
Random 3D points uniformly distributed on an ellipse shaped window of a sphere
close all
clear all
clc
%%
n = 1000;
z = rand(n,1)*2-1;
t = rand(n,1)*2*pi;
x = sqrt(1. - z.*z).*cos(t);
y = sqrt(1. - z.*z).*sin(t);
# "unitize" a vector
normalize(x) = x/norm(x)
# the [x|y] function
normcomp(x,y) = normalize(x - dot(x,y)*y)
# find the dihedral angle at a vertice `o`
dihedral(a,o,b) = acos(dot(normalize(cross(o,a)),normalize(cross(o,b))))
# the vertices of the triangle in the xy-plane
A2 = Float64[.1,.0,-2]
B2 = Float64[2,-.1,-2]
C2 = Float64[1.5,.9,-2]
@yakir12
yakir12 / Manifest.toml
Last active December 12, 2018 09:50
v1.0
[[AbstractFFTs]]
deps = ["Compat", "LinearAlgebra"]
git-tree-sha1 = "8d59c3b1463b5e0ad05a3698167f85fac90e184d"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "0.3.2"
[[AbstractPlotting]]
deps = ["ColorBrewer", "ColorTypes", "Colors", "Contour", "FileIO", "FixedPointNumbers", "FreeType", "FreeTypeAbstraction", "GeometryTypes", "ImageMagick", "IntervalSets", "LinearAlgebra", "Markdown", "Observables", "Packing", "PlotUtils", "Printf", "Random", "Serialization", "Showoff", "SignedDistanceFields", "StaticArrays", "Statistics", "UnicodeFun"]
git-tree-sha1 = "b47cc331607de0daa3d3e40ed77b61b36dd19c17"
repo-rev = "master"
using DataDeps, JuliaDB
register(DataDep("MWEdata", "The data needed for the MWE", "https://s3.eu-central-1.amazonaws.com/vision-group-file-sharing/Fun%20Stuff/cm.jldb", "5c19286fb4b39cddbc43708c98dc77a0766541b82cb1e462bc286286373ec813"))
cm = load(joinpath(datadep"MWEdata", "cm.jldb"))
cmg = groupby((coord = identity,), cm, :interval)
cmg[6].coord.t .-= cmg[6].coord.t[1] # ERROR: ReadOnlyMemoryError()