Acos In Dev C++

Acos In Dev C++ 4,5/5 364 votes

I am trying to calculate the angle between two vectors.

Acos In Dev C 2018

We're here anytime, day or night — 24/7. If you are a Veteran in crisis or concerned about one, connect with our caring, qualified responders for confidential help. Hello insiders, today we’re releasing build 83.0.478.5 to the Dev channel. This is our Beta release candidate for major version 83, and since it’s also not that much newer than last week’s Dev channel build, it’s a relatively light week this week in terms of changes. C Math acos This function computes the inverse cosine of a number in radian.

Here is my relevant code:

Point1 and Point2 are both unit vectors (using a vector class of my own design). The class function Point1.dot(Point2) calculates the dot product between Point1 and Point2 and I have verified that this works correctly. The dot product of two unit vectors should be the cos of the angle between them. So, acos() should give me the angle. But, it does not.

Here is the output:

Point1: 0.818436, -0.477041, 0.320304
Point2: -0.818436, 0.477041, -0.320304 Trumpet vst free download.

answer: -1

acos: 3.14150
Problem: nan
acos1: 0
a nan

The dump class function writes the vector.

You can see that the vectors are identical except that the signs of their elements are switched. So, the reported dot product between them is correctly reported as -1.

When I ask for acos(-1) I get the correct result of 3.14159 (PI) radians.

But, when I do acos(Point1.dot(Point2)) I get nan -- not a number -- as the result.

When I try double a=Point1.dot(Point2) and then ask for acos(a) I also get nan.

So, why do I get the correct answer of -1 as the dot product between my two vectors, but get nan when I ask for the acos of that result?

Why does acos() work sometimes, but not all the time?

I suspect that this is something very simple and I am just not seeing it. What am I missing?

DevDev

Using MinGW.

  • 4 Contributors
  • forum 5 Replies
  • 769 Views
  • 2 Weeks Discussion Span
  • commentLatest Postby ipswitchLatest Post

Dev C++ For Windows 10

David W131

Dev C++ 5.11

Edited by David W