Xah Talk Show 2019-12-14 hand writing Chinese, JavaScript coding vector dot product function style, intro to constructed language
topic talked:
- Drawing Tablet Drawing Tablet
- Logitech G502 Mouse Logitech G502 Mouse
- 常用汉字 Most Used Chinese Chars
- Chinese Characters Drum Keyboard
- Intro to Chinese Punctuation
- Drawing Tablet
- JavaScript, code function for dot product of vector of any dimension, function programing style
- JS: Function Rest Parameters
- Intro to Constructed Languages
- linguistics. flammable vs inflammable, active vs inactive, do vs undo vs understand, quasi pseudo semi.
- Volapük, Esperanto, Modern Hebrew
// we are going to write a bunch of functions that does matrix and vector multiplication // and these functions will work in any dimensions const cos = Math.cos; const sin = Math.sin; const π = Math.PI; // dot([a,b,c], [x,y,z] ); // this is what dot product means // is a*x + b*y + c*z // dot product of 2 vectors, vector must be 2D const f_vec_dot_2d = (([a1,a2] , [b1,b2] ) => (a1 * b1 + a2 * b2)) ; // dot product of 3 vectors, vector must be 3D const f_vec_dot_3d = (([a1,a2,a3] , [b1,b2,b3] ) => (a1 * b1 + a2 * b2 + a3 * b3)) ; // dot product of 2 vectors, vectors can be of any dimension const f_vec_dot = (( ... vectors) => vectors . reduce ((v1, v2) => v1. map ((x,i) => x * v2[i])) . reduce ( (a,b) => (a+b)) ); const vA = [1,2]; const vB = [3,4]; console.log ( f_vec_dot_2d(vA, vB) ); // 11 console.log ( f_vec_dot(vA, vB) ); // 11 const vC = [1,2,3]; const vD = [3,4,9]; console.log ( f_vec_dot_3d(vC, vD) ); // 11 console.log ( f_vec_dot(vC, vD) ); // 11 // vlen2D returns the length of the vector of a 2d vector const vlen2D = ((v) => Math.hypot(...v)) ; // f_vec_length returns the length of the vector const f_vec_length = ((v) => Math.hypot(...v)) ;