Questions tagged [hypotenuse]
22 questions
44
votes
5 answers
Why hypot() function is so slow?
I did some testing with C++ hypot() and Java Math.hypot. They both seem to be significantly slower than sqrt(a*a + b*b). Is that because of a better precision? What method to calculate a hypotenuse hypot function uses? Surprisingly I couldn't find…

Leonid
- 22,360
- 25
- 67
- 91
7
votes
4 answers
Triangle Trigonometry (ActionScript 3)
I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians.
I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the…

tags2k
- 82,117
- 31
- 79
- 106
4
votes
5 answers
C Program to Calculate Hypotenuse
I'm fairly new to coding and am currently learning C. In class I was given an assignment to write a program that calculates the hypotenuse of the triangle by using our own functions. However, there seems to be something wrong with the code that I…

Sean
- 2,890
- 8
- 36
- 78
3
votes
1 answer
How to print the pythagorean triple with the largest hypotenuse
I have to find all the pythagorean triples which have a value of "c" (where c is the hypotenuse) smaller than an integer number entered by the user. I was able to do this, however I also have to print which triple has the largest value of "c".
#…

the1whoknocks
- 89
- 1
- 2
- 6
3
votes
1 answer
The Math.hypo function
Why the math operation Math.sqrt(x*x+y*y) is much faster than Math.hypo(x,y)?
public class Teste {
public static void main(String[] args) {
long ta = System.currentTimeMillis();
for( double x=0,y=0; x<5000000; x++,y+=2 ){
…

heron
- 31
- 2
2
votes
1 answer
Libc hypot function seems to return incorrect results for double type... why?
#include
#include
int main(int argc, char** argv) {
#define NUM1 -0.031679909079365576
#define NUM2 -0.11491794452567111
std::cout << "double precision :"<< std::endl;
typedef…

Mathieu Tournier
- 23
- 4
2
votes
5 answers
How can I find the arctan of a right triangle using only the hypotenuse?
Okay, so I need to make C go the shortest path from A to B. A to B is the hypotenuse of my right triangle, and I need to give C the arctan of said triangle. How do I do this, and does the formula have a name?

William
- 8,630
- 23
- 77
- 110
2
votes
1 answer
C Program to find hypotenuse, hypotenuse found too big
This is my first program in C. When I run this the hypotenuse it finds is huge. I enter side A and B as 2 and the output is 130899047838401965660347085857614698509581032940206478883553280.000000. What did I do wrong?
#include
#include…

cuttinace
- 31
- 5
1
vote
2 answers
2d random walk in python - drawing hypotenuse from distribution
I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a…

eric p
- 235
- 5
- 13
1
vote
1 answer
How Find angle in php when we know base perpendicular and hypotenuse?
Find angle in php when we know base perpendicular and hypotenuse ?
I am making a project in PHP and need me some calculations but i am unable to imagine how to find out the angle when know base perpendicular and hypotenuse
Here is:AB = 3000 =…

dhna
- 71
- 2
- 10
1
vote
0 answers
how to return angle from hypotenuse with legs as parameters
the function returns the angle of the resulting hypotenuse from the calculus using the opposite leg (y) and the adjacent leg (x)
i don't understand this code, can anyone help me?
(the function in the context of << and >> symbols)
int…

user3818433
- 11
- 1
0
votes
2 answers
Hypotenuse of triangle Kotlin
Okay, pretty sure I got my formula right... don't think I quite understand how to call on methods, howcome mine isn't working?
fun main() {
println("Enter Width of the triangle")
readln()
println("Enter Height of the triangle")
…

Gilli
- 51
- 8
0
votes
1 answer
How to compute hypotenuse and bearing
I got the below code from @DanS at this link how-to-display-a-map-still-image-file-with-a-moving-current-location
onCurrentPosition(Location current){
double hypotenuse = upperLeft.distanceTo(current);
double bearing =…

eros
- 4,946
- 18
- 53
- 78
0
votes
1 answer
Calculating for the opposite side, given the hypotenuse and angle
May I ask what I'm doing wrong here? I'm trying to calculate for the opposite side, given the angle and hypotenuse. I feel like I'm using sine the wrong way. Need some clarification on why my code isn't working.
#include
#include…

Mere Pixel
- 3
- 3
0
votes
2 answers
Different results of Math.hypot() on Chrome and Firefox
When I run the simple calculation below the results on Chrome and Firefox slightly differ.
Chrome: 56.1124478168614
Firefox: 56.11244781686139
let x = -24.42;
let y = -50.519999999999925;
console.log(Math.hypot(x, y));
Is there a hole in the…

Waruyama
- 3,267
- 1
- 32
- 42