technical, a simple fast cosine
hi i just made a simple thing for when you need something that looks like a cosine but doesn't have to be super accurate. it's still kind of expensive (four multiplies), but otoh it's actually pretty close to a real cosine.
this is a by-product of when i optimized a magnetic field implementation for uni, which included a cosine. i learnt how to make this fast from naoki shibata's sleef library, though the rounding trick is mine c:
you can find my (hopefully well-explained) code here: https://github.com/antoniusf/CRPropa3/blob/fix-planewave-comments/src/magneticField/turbulentField/PlaneWaveTurbulence.cpp#L283
you could get a slightly more accurate result by tweaking the numbers a bit, but i like that they're so nice, so i'm keeping them.
also, this computes cos(2πx), instead of cos(x), meaning that it goes through a whole cycle in 1 unit instead of 2π units. this simplifies things.
round is a normal rounding function, i.e. rounds down for fractional parts < 0.5, and up for > 0.5.
cos(2πx):
reduced = x - round(x)
sq = reduced * reduced
((-64 * sq + 64) * sq - 20) * sq + 1
I'm thinking we should start a hashtag for calming photos of moss.
How does #Mosstodon sound to you all? 😁 Come join us! 🌱
Here's another photo, for luck! 🍀
Palpatine: did you get the email I sent you?
Vader: yes, my master
Palpatine: with the minion who hates Mondays?
Vader: it's very funny, my master
mutual aid request, medical
My boyfriend broke his glasses a couple months ago and finally has an eye exam appointment. He's already had to give up a job opportunity because he couldn't see, and he needs one soon or we may lose housing.
Before Saturday we need:
$85 eye exam
also ASAP:
~$15 Zenni glasses + S&H
I also do commissions! Please see pinned post!
https://paypal.me/nuktibromos
CashApp $nuktibromos
C++ programmer, Gentoo Linux user, Vulkan developer.
Working on creating the VR metaverse
https://mondradiko.github.io
my DMs are open to anyone who wants to be friends 😊