Home › Forums › Programming › how can i convert polarAngle, aziumthalAngle, and distance to vector3.
Tagged: aziumthalAngle, polarAngle, tween
- This topic has 5 replies, 4 voices, and was last updated 4 years ago by eatdesignlove.
-
AuthorPosts
-
2020-11-25 at 12:58 pm #35864eatdesignloveParticipant
Hi, I need your help.
I know that i can get polarAngle, aziumthalAngle from app.controls objects.I wanna vector3 values from polarAngle, aziumthalAngle, and distance between orbitCamera’s position and targetPoint’s position to use control.tween method. Also I am not sure whether I exactly calculated the distance though.
—
#Get Distance
const dx = camera.position.x – targetPoint.x;
const dy = camera.position.y – targetPoint.y;
const dz = camera.position.z – targetPoint.z;
const distance = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2) + Math.pow(dz, 2));
—So my point is how can i convert polarAngle, aziumthalAngle, and distance to vector3. It would be very helpful if you let me know how to do that.
Many thanks.
2020-11-26 at 9:17 am #35941Yuri KovelenovStaff2020-11-26 at 4:14 pm #35993eatdesignloveParticipantHi,
As you can see the screenshot i attached, in the document it shows that i need to get vector3 value for tweening.
Unfortunately, I’m not familiar with the scalar value.😢
{x: number, y: number, z: number} <- Is that scalar value?
For your understanding, I write down what i want to do with the position variable’s value.
<input id=”polarAngle”>
<input id=”aziumthalAngle”>
<input id=”distance”>
<button onclick=”tweenViewClick”>Tween Viewer<button>function tweenViewClick() {
const polar = document.getElementById(‘polarAngle’);
const aziumthalAngle = document.getElementById(‘aziumthalAngle’);
const distance = document.getElementById(‘distance’);// … some logic … how to..
const postion = {x:.. , y:.., z:.. } // Calculated polarAngle, aziumthalAngle, distance.
app.controls.tween(postion, targetPosition);
}I want to know x, y, and z value by calculating polarAngle, aziumthalAngle, and distance…😢
Attachments:
You must be logged in to view attached files.2020-11-27 at 1:17 am #35996derekwang0605CustomerI just used below it works ok.
tweenCamera([30, 30, 10], [0, 0, 0], 10, function() {}, 1);2020-11-27 at 9:27 am #36007Ivan LyubovnikovStaffHi,
You might find this method useful: Vector3.setFromSphericalCoords(radius, phi, theta), where phi is the polar angle and theta is aziumthal.
Co-founder and lead developer at Soft8Soft.
2020-12-01 at 5:03 am #36116eatdesignloveParticipantThank to you i figured it out!
–
const vector3 = new v3d.Vector3();
const position = vector3.setFromSphericalCoords(
distance,
controls.getPolarAngle(),
controls.getAzimuthalAngle()
); -
AuthorPosts
- You must be logged in to reply to this topic.