4 ms·
/* Produce a quaternion from an axis-angle representation.*/ function quat_from_axis(theta: number, x: number, y: number, z: number) { const halfcos =
by oneshtein 1y ago
/* Produce a quaternion from an axis-angle representation.*/
function quat_from_axis(theta: number, x: number, y: number, z: number) {
const halfcos = Math.cos(theta * 0.5);
const halfsin = Math.sin(theta * 0.5);
return new Quaternion(
halfcos,
axis[0] * halfsin,
axis[1] * halfsin,
axis[2] * halfsin,
);
}
Function is vibe coded.
- noodlejs 1y agoHi! Author here. I hand wrote this website and the source code of the examples mostly comes from my own debugging tools. That method in particular is just a very minimal implementation of section 8.5.2 of this textbook (but I tried to make it friendly for the blog post). https://gamemath.com/book/orient.html#quaternion_geometry https://gamemath.com/book/orient.html#quaternion_geometry
- polishdude20 1y agoSorry, but x,y and z are not even being used in that function...
- noodlejs 1y agoLOL ok yeah, that's a copy-paste issue. I'll fix it up here shortly.
- xeonmc 1y agoimo it's better to express the conversion relation as exp-log pairs: fn exp(q: Quat) -> Quat { let ijk = sqrt(q.i*q.i + q.j*q.j + q.k*q.k); Quat { i: exp(q.l) * sin(ijk) * q.i / ijk, j: exp(q.l) * sin(ijk) * q.j / ijk, k: exp(q.l) * sin(ijk) * q.k / ijk, l: exp(q.l) * cos(ijk), } } fn log(q: Quat) -> Quat { let ijk = sqrt(q.i*q.i + q.j*q.j + q.k*q.k); Quat { i: atan2(ijk, q.l) * q.i / ijk, j: atan2(ijk, q.l) * q.j / ijk, k: atan2(ijk, q.l) * q.k / ijk, l: 0.5 * log(q.i*q.i + q.j*q.j + q.k*q.k + q.l*q.l), } }
- feoren 1y agoWhat makes you so confident that you can tell that a 3-line function is AI? Especially given that the author denies it, with evidence.
- CamperBob2 1y agoThen again, that's just the AI would say...
- oneshtein 1y agoIt cannot work, because x,y,z are not used at all.
- margalabargala 1y agoThis looks more like a copy paste error, where the function signature requests xyz, but the function itself uses an undefined array "axis" of which xyz correspond to indexes 0-2. The code is correct aside from the obvious bug. Bugs predate the existence of AI by decades. This particular bug doesn't look like one an AI would write.
- throwaway290 1y agounused variables is typical LLM. Also it's a short function. It's impossible to miss unused parame if you read your own code at all. And if you somehow don't... then it's deserved anyway.
- cindyllm 1y ago[dead]
- margalabargala 1y agoMaybe typical LLM of a year ago. If a function was one-shot written by an LLM today, it would not make that mistake. It could make that mistake if it writes the header at one point, and the body separately. Though that's unlikely. But I suspect this is a genuine human error.
- ARob109 1y agoI've been seeing "that's vibe coded" comments a lot lately on posts. Comments that call out code that may or may not be vibe-coded. At what point should these types of posts start getting down-voted? It's not constructive, and IMO imparts a negative connotation. HN: Show HN Awesome New LLM can Code!! Also HN: TFA is vibe coded angry pitchfork or ugh
- RossBencina 1y agoYes, and low effort backhanded comments about "AI slop" are also getting tiresome.
- bubblyworld 1y agoI agree, this is becoming HN's new favourite way to detail a conversation unproductively. It's up there with doxxing and ad hominems in my opinion - unverifiable and usually antagonistic.
- dzidol 1y agoI love vibe coding. Even the variables don't match (x, y, x vs axis[3]) and the coder is left with no knowledge what's they doing. You'll probably either prompt for fixing it or fix it yourself, but will still not get substantial amount of the domain knowledge -- and let's be honest, this is example just the simplest term there, that's why the code is so easy to correct even without thinking...
- dzidol 1y agoI just figured out from subcomments it's an excerpt from article, so my comment just doesn't fit here (thought author of the comment I replied to just braged they can vibe code something ad hoc and don't need to read about domain). Apologies for the mistake (still keeping my opinion about vibe coding).