473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

trigonometical,rad,acos... HELP please

this function should return the degrees of the (AOB) angle. I tested it on a
value of 30° and it returned 36,869896, with the points declaration:
a.x=0;a.y=0;
b.x=3;b.y=4;
c.x=0;c.y=4;
and the call to the function:
alfa =winkelgroesse(b,a,c);
here is it:

float winkelgroesse(punkt m,punkt o,punkt n){ float a,b,c,alfa;
c=powf(m.x-n.x,2)+powf(m.y-n.y,2);
a=sqrtf(powf(o.x-n.x,2)+powf(o.y-n.y,2));
b=sqrtf(powf(o.x-m.x,2)+powf(o.y-m.y,2));
alfa=acosf((powf(a,2)+powf(b,2)-c)/(2*a*b));
alfa=180*alfa/PI;
return alfa; }

did i make a mistake at converting rad to degrees ?

--
it's not right. it's not even wrong
Nov 14 '05 #1
4 1637
In article <52******************@news.chello.at>,
apropo <fl***********@yahoo.com> wrote:
this function should return the degrees of the (AOB) angle. I tested it on a
value of 30° and it returned 36,869896, with the points declaration:
a.x=0;a.y=0;
b.x=3;b.y=4;
c.x=0;c.y=4;
and the call to the function:
alfa =winkelgroesse(b,a,c);
here is it:

float winkelgroesse(punkt m,punkt o,punkt n){ float a,b,c,alfa;
c=powf(m.x-n.x,2)+powf(m.y-n.y,2);
a=sqrtf(powf(o.x-n.x,2)+powf(o.y-n.y,2));
b=sqrtf(powf(o.x-m.x,2)+powf(o.y-m.y,2));
alfa=acosf((powf(a,2)+powf(b,2)-c)/(2*a*b));
alfa=180*alfa/PI;
return alfa; }


The 36,869896 (36.869896 for Americans) is correct, as it is the
size of the angle "o" in the triange that you have specified.

Why are you expecting of 30°?
--
Rouben Rostamian
Nov 14 '05 #2
lol, I have to confess, I'm sooo stupid. Sorry for disturbing the group.
:-)

--
it's not right. it's not even wrong
Nov 14 '05 #3

"apropo" <fl***********@yahoo.com> wrote in message
news:52******************@news.chello.at...
this function should return the degrees of the (AOB) angle. I tested it on a value of 30° and it returned 36,869896, with the points declaration:
a.x=0;a.y=0;
b.x=3;b.y=4;
c.x=0;c.y=4;
and the call to the function:
alfa =winkelgroesse(b,a,c);
here is it:

float winkelgroesse(punkt m,punkt o,punkt n){ float a,b,c,alfa;
c=powf(m.x-n.x,2)+powf(m.y-n.y,2);
a=sqrtf(powf(o.x-n.x,2)+powf(o.y-n.y,2));
b=sqrtf(powf(o.x-m.x,2)+powf(o.y-m.y,2));
alfa=acosf((powf(a,2)+powf(b,2)-c)/(2*a*b));
alfa=180*alfa/PI;
return alfa; }

did i make a mistake at converting rad to degrees ?


Und wie geht das in die andere Rictung? Es werden degrees gegeben und Sie
wollen rads. MPJ
Nov 14 '05 #4
apropo wrote:
this function should return the degrees of the (AOB) angle. I tested it on a
value of 30° and it returned 36,869896, with the points declaration:
a.x=0;a.y=0;
b.x=3;b.y=4;
c.x=0;c.y=4;
Well, why did you think a 3-4-5 triangle has any 30 degree angles in it?
and the call to the function:
alfa =winkelgroesse(b,a,c);
here is it:

float winkelgroesse(punkt m,punkt o,punkt n){ float a,b,c,alfa;
c=powf(m.x-n.x,2)+powf(m.y-n.y,2);
a=sqrtf(powf(o.x-n.x,2)+powf(o.y-n.y,2));
b=sqrtf(powf(o.x-m.x,2)+powf(o.y-m.y,2));
alfa=acosf((powf(a,2)+powf(b,2)-c)/(2*a*b));
alfa=180*alfa/PI;
return alfa; }

did i make a mistake at converting rad to degrees ?


You misspecified the triangle.

#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846L

typedef struct
{
double x, y;
} punkt;

inline double square(double x)
{
return x * x;
}

double winkelgroesse(punkt m, punkt o, punkt n)
{
double a, b, c;
c = square(m.x - n.x) + square(m.y - n.y);
a = square(o.x - n.x) + square(o.y - n.y);
b = square(o.x - m.x) + square(o.y - m.y);
return 180 * acos((a + b - c) / (2 * sqrt(a * b))) / PI;
}

int main(void)
{
punkt a, b, c;
double alfa;
a.x = 0;
a.y = 0;
b.x = sqrt(3);
b.y = 0;
c.x = sqrt(3);
c.y = 1;
alfa = winkelgroesse(b, a, c);
printf("alfa = %g\n", alfa);
}

[output]
alfa = 30
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
1
by: ctether | last post by:
I have never created my own program before (I'm in college right now), and I have to create a program for the length c on any triangle using sides a, b, and theta angle c. Here is what I have so far...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
1
by: radskate360 | last post by:
Hi I am newer to programming and need a bit of help with this program. OK, heres the directions. The distance between two places on earth can be calculated by using their latitudes and...
3
by: Olumide | last post by:
Hi - I'm computing the angle between pairs of unit vectors as the arc cosine of the dot product of each pair of vectors. Occasionally, when the dot product is 1.000000 (output to 6 decimal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.