I found a code from internet and try to understand it. I don’t know what is the programming language of the code and try to find javascript equivalencies or workarounds.
A) Which language is in question?
*a_offsetrot = PI / 4.0f;
B) What is the meaning of ‘*’ in above and what is the possible Javascript equivalence?
C) What is the meaning of ‘f’ and what is the possible Javascript equivalence?
if (K<0) K = 0; else K = (float)sqrt (K);
D) What is the meaning of ‘(float)’ and what is the possible Javascript equivalence?
*a_offsetrot = 0.5f * (float)atan2(B,ac);
E) What is the meaning of “atan2” and what is the possible Javascript equivalence?
void Ellipse_Transform (float * a_rh, float * a_rv, float *a_offsetrot, Vector2 * endpoint, matrix * a_mat, int *a_ReverseWinding)
F) What is the meaning of ‘Vector2 * endpoint’ and is there possible Javascript equivalence? Is Vector2 a thing that has two (x,y)-points or only one (x,y)-point?
m[0] = a_mat->m[0] * +rh * c + a_mat->m[3] * rh * s;
G) What is the meaning of ‘a_mat->m[0]’ and what is the possible Javascript equivalence?
EDIT: Updated title to be more meaningful.
EDIT2: Thanks to constructive answer of @rid I got the C language code translated to Javascript and it is HERE and full working functional example is HERE.
A) The language is C.
B)
*is the dereferencing operator. There is no equivalent in JavaScript, since JavaScript does not use pointers.C) The
fin4.0findicates that the value is afloatvalue. There is no equivalent in JavaScript, since in JavaScript all numeric values are represented as numbers.D)
(float)is a type cast. Something similar in JavaScript isparseFloat()which will parse the argument and return a floating point number, but this is different from type casting, and there is no equivalent to type casting in JavaScript.E)
atan2()is a math function for calculating the arctangent. You can find it in the standard JavaScriptMathpackage.F) A
Vector2is most likely a structure that has two properties, anxproperty and ayproperty.G)
a_mat->m[0]means the first element from the arraymthat is a property ofa_mat. Ifa_matwas an object in JavaScript, the equivalent would bea_mat.m[0].