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.
reduced = x - round(x)
sq = reduced * reduced
((-64 * sq + 64) * sq - 20) * sq + 1
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
~$15 Zenni glasses + S&H
I also do commissions! Please see pinned post!
C++ programmer, Gentoo Linux user, Vulkan developer.
Working on creating the VR metaverse
my DMs are open to anyone who wants to be friends 😊
*Due to increased bot signup, manual approval is temporarily required. Please write some applicable request text on signup.*
This Mastodon instance is for tech workers, academics, students, and others interested in tech who are LGBTQIA+ or Allies.
We have a code of conduct that we adhere to. We try to be proactive in handling moderation, and respond to reports.
We're not a free speech absolutist. We're not interested in Nazis, TERFS, or hate speech.
This instance is meant to be a friendly, welcoming space to all who are willing to reciprocate in helping to create that environment.
If you’re ever unsure, ask first. Use CWs where required.
If you’re accused of causing harm, either take some responsibility or ask moderators for help.
Our moderators are here to listen and respond to reports.
This instance is funded in part by Patreon donations.