0
我無法理解函數labelBox中使用的此行代碼this.position = convertlatlonToVec3(cardinal.lat, cardinal.lon).multiplyScalar(radius);
。 multiplyScalar(半徑)如何工作。我無法理解使用JavasScript執行以下數學公式:
function convertlatlonToVec3(lat, lon)
{
var cosLat = Math.cos(circle.getCenter().lat() * degrees);
var sinLat = Math.sin(circle.getCenter().lat() * degrees);
var xSphere = radiusEquator * cosLat;
var ySphere = 0;
var zSphere = radiusPoles * sinLat;
var rSphere = Math.sqrt(xSphere*xSphere + ySphere*ySphere + zSphere*zSphere);
var tmp = rSphere * Math.cos(lat * degrees);
xSphere = tmp * Math.cos((lon - circle.getCenter().lng()) * degrees);
ySphere = tmp * Math.sin((lon - circle.getCenter().lng()) * degrees);
zSphere = rSphere * Math.sin(lat * degrees);
var x = -ySphere/circle.getRadius();
var y = (zSphere*cosLat - xSphere*sinLat)/circle.getRadius();
var z = 0;
return new THREE.Vector3(x, y, z);
}
function labelBox(cardinal, radius, root)
{
this.screenvector = new THREE.Vector3(0,0,0);
this.labelID = 'MovingLabel'+ cardinal.ID;
this.position = convertlatlonToVec3(cardinal.lat, cardinal.lon).multiplyScalar(radius);
}
'convertlatlonToVec3'返回'新THREE.Vector3(X,Y,Z)'...這可能有一個方法稱爲'multiplyScalar' - 隨後執行 –
@Jaromanda XI需要知道multiplyScalar(radius)是如何工作的。 – lakers1234
所以現在你已經改變了這個問題 - 你看過three.js文檔嗎? –