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 GeometryBasics, LinearAlgebra, GLMakie, FileIO, CoordinateTransformations, ColorSchemes | |
function intersect_line_sphere(p::Point3f, d::Point3f, c::Point3f, sphere_radius::Float32) | |
# Use indexing to access point/vector components | |
# Calculate coefficients of the quadratic equation (a*t^2 + b*t + c = 0) | |
a = dot(d, d) | |
b = 2 * dot(d, p .- c) | |
c = dot(p .- c, p .- c) .- sphere_radius^2 | |
# Calculate discriminant |
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
#!/usr/bin/env python3 | |
def view_dict(d: dict): | |
'''View a (nested) dictionary in a new VSCode paneas a temp file for inspection''' | |
from yaml import dump | |
from tempfile import NamedTemporaryFile | |
from os import system | |
from subprocess import call | |
with NamedTemporaryFile(suffix=".yml") as f: |
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
l <- list( | |
list( | |
list( | |
a = 1 | |
) | |
) | |
) %>% | |
enframe() | |
# How to simplify this repetetive code? |
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
library(tidyverse) | |
library(eulerr) | |
library(ggforce) | |
#' Area proportional venn diagrams | |
#' | |
#' This functions uses eulerr::euler to plot area proportional venn diagramms | |
#' but plots it using ggplot2 | |
#' | |
#' @param combinations set relationships as a named numeric vector, matrix, or data.frame(See `eulerr::euler`) |
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
#' Assignment expression operator | |
#' | |
#' Creates an object with name `lhs` with the value `lhs` | |
#' and finally returns the value e.g. to pipe and print it | |
`%:=%` <- function(lhs, rhs, envir = parent.frame()) { | |
assign(deparse(substitute(lhs)), rhs, envir = envir) | |
rhs | |
} | |
# Create a varaible and print it's value |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.