Considering the following JavaScript code that runs in Node.js is there any way to change the input data according to below statements ?
Since I am a newbie in JS I do not understand if it passes the header meaning pointer or a value .
- u_new = u cos(v)
- v_new = u sin(v)
setData (data) {
if (data.length > 1) {
this.u.data = data[0].data
this.v.data = data[1].data
this._baseLayer.setData([this.u , this.v])
Layer.prototype.setData.call(this, data)
}
},
setModel (model) {
let modelHeader = {
...
}
Object.assign(this.u.header, modelHeader)
Object.assign(this.v.header, modelHeader)
Layer.prototype.setModel.call(this, model)
}
Original inputs u and v are arrays in this format :
This is u data array
["NaN","NaN","NaN","NaN","NaN",0.77,0.76,0.75,0.84,0.94,1.03,1.11,"NaN"]
This is v data array
Note that v values are in degrees while JavaScript's Math read radians.
["NaN","NaN","NaN","NaN","NaN",187.21,189.48,190.58,192.54,194.48,"NaN",197.21,198.09]
I have already tried the following without any success, I can't see any animation running (I animate u-v vectors) :
// radians = degrees * PI / 180
this.u.data = data[0].data * Math.cos(data[1].data * Math.PI / 180)
this.v.data = data[0].data * Math.sin(data[1].data * Math.PI / 180)
If such a data processing is not possible should I modify the arrays before I pass them as input to JS ?