In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to find the angle of javascript". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to find the angle of javascript".
The method of finding the angle of javascript: 1, create the method of "function angle (start,end) {...}"; 2, execute the statement "angle ({XRV 0) YRV 0}, {XRV 1) YRO 1}".
This article operating environment: windows7 system, javascript1.8.5 version, DELL G3 computer.
How does javascript find the angle?
Angle calculation in js:
-,
Js's understanding of Radian and Angle of Trigonometric function algorithm and their conversion
Two unit degrees and arcs of angles
1. The definition of radians
We know that the definition of "degree" is, "two rays are emitted from the center of the circle to the circumference of the circle, forming an arc with an angle directly opposite to the angle. When the arc length is exactly equal to one-360 of the circumference of the circle, the angle between the two rays is 1 degree. (figure 1)
2. How is the Radian defined? Radians are defined as two rays emitting from the center of the circle to the circumference, forming an arc with an angle directly opposite to the angle. When the arc length is exactly equal to the radius of the circle, the angle between the two rays is 1 Radian. (figure 2)
By comparison, the two definitions of degrees and radians are very similar. The only difference between them is that the arc length of the angle is different. The degree is equal to one-360 of the circumference of the circle, while the Radian is equal to the radius.
Simply put, radians are defined as 1 radians when the arc length of the angle is equal to the radius.
The pictures related to this topic are as follows:
If the arc length of the angle is several times the radius, then the size of the angle is several radians.
Their relationship can be expressed and calculated by the following formula:
Angle (Radian) = Arc length / Radius
The circumference of a circle is 2 π times the radius, so a circumferential angle (360 degrees) is 2 π radians.
The length of a semicircle is π times the radius, so a flat angle (180 degrees) is π radians.
Conversion between degrees and radians
A circle: π: 3.14.
360 °= 2 π
π = 180; so we know that 1 degree is equal to π / 180;
Write "π" as "PI" in js code. Because "π" and "sin" are both "mathematical functions", it is required to add "Math." (Math is the abbreviation of "mathematics" Mathematics in English), and then write "Math.PI" and "Math.sin", that is to say, π should be written as Math.PI,sin () in js and Math.sin ().
It is as follows:
Sin30 °has to be written as Math.sin (30*Math.PI/180). The part in the small parentheses turns 30 °into radians, that is, 30 × π / 180.
"I'm more than happy to spend a day programming to automate a task, unless it takes only 10 seconds to complete manually."
It's just a math problem, isn't it?
Function angle (start,end) {var diff_x = end.x-start.x, diff_y = end.y-start.y; / / returns the angle, not Radian return 360*Math.atan (diff_y/diff_x) / (2*Math.PI) } then the execution of angle ({xlv 0djv 0}, {XRL 1D YRV 1}) will return 45 (degrees) thank you for your reading. The above is the content of "how to find the angle of javascript". After the study of this article, I believe you have a deeper understanding of how to find the angle of javascript, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.