[tex](adsbygoogle = window.adsbygoogle || []).push({});

A=-[(x_i-X_j)cos\theta_j + (y_i-Y_J)sin\theta_j]

[/tex]

[tex]

B = (x_i-X_j)^2+(y_i-Y_j)^2

[/tex]

[tex]

E=(B-A^2)^{1/2}=(x_i-X_j)sin\theta_j+(y_i-Y_j)\theta_j

[/tex]

I implemented this in C++ as follows

A = -(p_c(0)(i) - p_v(0)(j))*cos(angle(j)) - (p_c(1)(i) - p_v(1)(j))*sin(angle(j))

B = (p_c(0)(i) - p_v(0)(j))*(p_c(0)(i) - p_v(0)(j)) + (p_c(1)(i) - p_v(1)(j))*(p_c(1)(i) - p_v(1)(j))

E=(p_c(0)(i) - p_v(0)(j))*sin(angle(j)) + (p_c(1)(i) - p_c(1)(j))*cos(angle(j))

F= sqrt(B-A*A)

(All parantheses instead of square brackets in arrays to avoid HTML encoding)

where

p_c(0)(i) =[tex]x_i[/tex]

p_c(1)(i) = [tex]y_i[/tex]

p_v(0)(j) = [tex]X_j[/tex]

p_v(1)(j) = [tex]Y_j[/tex]

angle(j) = [tex]\theta_j[/tex]

Well, here's the deal. Mathematically

[tex]E=(B-A^2)^{1/2}=(x_i-X_j)sin\theta_j+(y_i-Y_j)\theta_j[/tex]

However in C++, I am gettingdifferentvalues for E and F in C++ when mathematically they are the same. I am going insane.

Please help

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# I'm going crazy

**Physics Forums | Science Articles, Homework Help, Discussion**