Answer the question
In order to leave comments, you need to log in
Why does the program output -nan (ind)?
Wrote a function to rotate a straight line.
// Line - y = _k * x + _b
void Line::rotation(double angle) {
double temp = _k;
_k = (_k + tan(angle))/(1 - _k*tan(angle));
_b *= _k/temp;
}
double Line::rotationAngle(const Line &l) { // counterclock-wise from l to this
return atan((_k - l._k)/(1. + _k*l._k));
}
Line Line1(0, 0), Line2(2, 1);
cout << Line1;
cout << Line2;
Line1.rotation(Line2.rotationAngle(Line1));
cout << Line1;
y = 0x + 0
y = 2x + 1
y = 2x + -nan(ind)
_b *= _k/temp;
y = 2x + 0
Answer the question
In order to leave comments, you need to log in
It seems to be no roots and divisions by zero.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question