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(cgalMeshes) | |
library(rgl) | |
# https://laustep.github.io/stlahblog/posts/TennisBall.html #### | |
f <- function(x, y, z) { # Enneper surface: f=0 | |
64*z^9 - 128*z^7 + 64*z^5 - 702*x^2*y^2*z^3 - 18*x^2*y^2*z + | |
144*(y^2*z^6-x^2*z^6) + 162*(y^4*z^2-x^4*z^2) + 27*(y^6-x^6) + | |
9*(x^4*z+y^4*z) + 48*(x^2*z^3+y^2*z^3) - 432*(x^2*z^5+y^2*z^5) + | |
81*(x^4*y^2-x^2*y^4) + 240*(y^2*z^4-x^2*z^4) - 135*(x^4*z^3+y^4*z^3) | |
} |
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(rgl) | |
library(Rvcg) | |
# vertices #### | |
nvertices <- 64L | |
vertices <- | |
rbind( | |
c(-1, -1, -1, -1 - sqrt(2)), | |
c(1, -1, -1, -1 - sqrt(2)), | |
c(-1, 1, -1, -1 - sqrt(2)), |
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
#version 3.8; | |
global_settings { assumed_gamma 1 } | |
#include "colors.inc" | |
#include "textures.inc" | |
/* camera */ | |
camera { | |
location <-11, 7,-32> | |
look_at 0 | |
angle 45 |
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 LinearAlgebra | |
using Quaternions | |
using Meshes | |
using MeshViz | |
using GLMakie | |
function quaternionFromTo(u, v) | |
re = 1 + sqrt((1.0 + dot(u, v)) / 2.0) | |
w = cross(u, v) / 2.0 / re | |
return Quaternion(re, w[1], w[2], w[3]) |
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(rgl) | |
triangulateFace <- function(face) { # only for convex face ! | |
M <- matrix(NA_integer_, nrow = 3L, ncol = length(face)-2L) | |
for(i in 2L:(length(face)-1L)) { | |
M[, i-1L] <- c(face[1L], face[i], face[i+1L]) | |
} | |
M | |
} |
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
triangulateFace <- function(face) { # only for convex face ! | |
M <- matrix(NA_integer_, nrow = 3L, ncol = length(face)-2L) | |
for(i in 2L:(length(face)-1L)) { | |
M[, i-1L] <- c(face[1L], face[i], face[i+1L]) | |
} | |
M | |
} | |
# http://dmccooey.com/polyhedra/GreatDodecicosahedron.html | |
C0 = (3 - sqrt(5)) / 4 |
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
*.Rproj | |
.Rproj.user/ | |
.Rhistory |
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
*.Rproj |
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(rgl) | |
iota <- function(x) x / c(crossprod(x)) | |
q <- cgalMeshes:::quaternionFromTo(c(1, 1, 1)/sqrt(3), c(1, 0, 0)) | |
R <- onion::as.orthogonal(q) | |
cube <- as.tmesh3d( | |
translate3d( |