Skip to content

Instantly share code, notes, and snippets.

---
title: "A graphics workflow"
author: "baptiste"
date: 2018-20-05
---
Glyphs are positioned by x and y coordinates; other parameters are kept separate as they may differ from glyph to glyph and, crucially, compound glyphs contain nested glyphs with their own properties, requiring a flexible container.
The structure of a glyph is thus as follows,
# library(cubs)
library(Ryacas)
Ylm <- function(l,m,phi,theta){
ex <- Ryacas::yac_expr(glue::glue("(-1)^{m}*(1-x^2)^({m}/2)*D(x,{m})OrthoP({l}, x)"))
sqrt((2*l+1)/(4*pi) * factorial(l-m) / factorial(l+m))*
exp(1i*abs(m)*phi) * eval(ex, list(x = cos(theta)))
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.
library(vwline)
library(gridGeometry)
library(hershey)
library(ggplot2)
library(scales)
w <- c(0, .2, 0)
gl <- list()
library(gridExtra)
library(grid)
N <- 15
N2 <- 8
d <- matrix(sample(seq(1,N2,by=2)^2, N^2,replace = T),N,N)
myfun <- function(label, ...){
i <- as.numeric(label)
n <- sqrt(i)
arrangeGrob(grobs=replicate(i, rectGrob(gp=gpar(fill=grey(runif(1,0.5+0.2*n/N2,0.9-0.2*n/N2)),col='white', lwd=1)),
library(chipmunkbasic)
library(chipmunkcore)
library(ggplot2)
N <- 2
cm <- Chipmunk$new(time_step = 0.005)
cm$add_static_segment(-70, 0, 120, 0, friction = 0, elasticity = 1)
cm$add_static_segment(-70, 0, -70, 30, friction = 0, elasticity = 1)
## visualising some spherical harmonics on a sphere
## with 3d interactive plot
## Ylm is a scalar field defined at surface points
## E is a vector field defined at those points
library(rgl)
library(dplyr)
library(RColorBrewer)
m <- matrix(c(0,1), nrow = 600, ncol=800)
lm <- replicate(100, jitter(m, 20), simplify = FALSE)
library(Cairo)
CairoX11()
plot.new()
system.time({
@baptiste
baptiste / Progress-Pride-Flag-Daniel-Quasar_vector.svg
Last active June 17, 2020 08:43
Progress-Pride-Flag-Daniel-Quasar_vector
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.