- 501

- 0

## Main Question or Discussion Point

[tex]

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 getting

Please help

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 getting

*different*values for E and F in C++ when mathematically they are the same. I am going insane.Please help

Last edited: