Getting screen coordinates based on triangles

If I have the length of the hypotenuse and its angle, how can I find the neighboring and the opposite?

I write this in JavaScript, and I'm just trying to find the coordinates of the screen (x / y), where the end of the hypotenuse is given by the length and angle. So in addition, I need to know how to convert from Cartesian coordinates to screen coordinates.

Sorry, this is probably a pretty dumb question.

Here is a sketch if I'm unclear:

alt text

So something like this:

function getLineEndCoords(originX, originY, hypotenuse, angle){
    // Probably something to do with tangents and cosines.
    return [x,y]
}

Also, if anyone knows good JS libraries for this kind of material (isometric drawings related to math mapping) that would be convenient.

+3
source share
2 answers

Here you go:

function getLineEndCoords(originX, originY, hypotenuse, angle){
  return [originX+Math.cos(angle)*hypotenuse,originY-Math.sin(angle)*hypotenuse];
  }

x ( ). , 0 3 . PI/2 (90 ) 12 . , Y , , , .

, javascript , . . :

function deg2rad(deg){
  return deg*Math.PI/180;
  }
+3

soh cah toa:

sin(A) = o/h
cos(A) = a/h

:

x = hypotenuse*sin(angle) + origionX
y = hypotenuse*cos(angle) + origionY

, , , - , .

EDIT:

, .

+4

Source: https://habr.com/ru/post/1787180/


All Articles