You're incorrect. It is, in fact, "firedraco and me". We were not the subject of the sentence, therefore you don't use the subject form of the pronoun.
The easy way to remember is to remove "firedraco and" and see how it sounds. You wouldn't say "I'm glad you know so much about I".
Good point. If someone wants to truly learn about a subject they will probably do extensive research before resorting to asking questions.
Again, I'm not opposed to him asking questions. I never was. I'm all for helping him with his questions.
My problem is that he asked for a full solution to his homework problem.
// find length of side a using p1 and p2
double a = sqrt( ( p2.get_x()-p1.get_x() )*( p2.get_x()-p1.get_x() ) + ( p2.get_y()-p1.get_y() )*( p2.get_y()-p1.get_y() ) );
// find length of side b
double b = // as above using p2 and p3 - simply substitute p3 for p1
// find length of side c
double c = // as above using p1 and p3
double cosMin = 0.0;// so it's initialized
if( a<b && a<c )// then a is the shortest side
cosMin = ( b*b + c*c - a*a )/(2.0*b*c);// from law of cosines
else
{
if( b<a && b<c )// b is shortest
cosMin = ( a*a + c*c -b*b )/(2.0*a*c);
else// c is shortest
cosMin = ( a*a + b*b -c*c )/(2.0*
Sqrt? Conditions? WTF?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class Vector2 {
public:
double x;
double y;
Vector2(double ax, double ay): x(ax), y(ay) { }
Vector2 operator- (const Vector2& v) { return Vector2(x - v.x, y - v.y); }
doubleoperator* (const Vector2& v) { return x * v.x + y * v.y; }
};
Vector2 a(x1, y1); // x1, y1 read from user input
Vector2 b(x2, y2); // x2, y2 read from user input
Vector2 c(x3, y3); // x3, y3 read from user input
double angle1 = acos((a-b)*(a-c));
double angle2 = acos((b-a)*(b-c));
double angle3 = acos((c-a)*(c-b));
xorebxebx, sure, classes are nice, but I'll point out some flaws anyway:
1. the most simple one : OP most likely has no clue what classes are.
2. your code doesn't quite do what it's supposed to:
a) no relation to the library OP uses
b) angle1 = acos((a-b)*(a-c)) is only true if a-b and a-c are unit vectors (sqrt here).
c) it doesn't choose the smallest angle (conditions here).
Generally I consider it inappropriate to wrap such trivial computations in classes (Though of course a decent library would provide a vector class). The way I'd do it is.
1 2 3 4 5 6 7 8 9 10
double GetLen(double x, double y){ return sqrt(x*x + y*y); }
double a = Getlen(p1.get_x()-p2.get_x(), p1.get_y()-p2.get_y());
double b = Getlen(p1.get_x()-p3.get_x(), p1.get_y()-p3.get_y());
double c = Getlen(p3.get_x()-p2.get_x(), p3.get_y()-p2.get_y());
if(c > a) std::swap(c, a);
if(c > b) std::swap(c, b);
float minimal_angle_cosine = ( a*a + b*b - c*c )/ 2/ a/ b;
@ firix: As you pointed out this is a forum. A public forum. Don't waste your time trying to police it to your own wimpy, politically correct standards. Disch and company has as much right to voice their opinions about other posters as you do to voice yours about them. These sites have moderators to step in if things get out of hand and they really don't need your help doing their jobs.
@ alexbg: I don't think Disch is angry at the world. Perhaps he simply doesn't like the idea of someone taking the easy way out by taking credit for someone else's work. I agree with his assessment that you probably didn't learn anything this way. Find out. Now that you've seen how to do it, open a blank C++ editor right now and try to write it yourself. I'll bet you can't but you need to be able to because next weeks studies will rely on the foundation you should have learned this week.
@ Disch: I know you don't need me coming to your rescue or speaking for you. This is just one of those threads that's gotten emotionally charged and people like to add their 2 sense (ha).
@cnoeval:What are you talking about.who are you.You speak such nonsense.Advocate, and I do not blame anyone.unbalanced unbalanced speech.The only problem is my lack of want..You understand kuzo
so do not ask questions out of the man says.
asks the man.
should ask.
does not want to answer do not want to answer.
Do you understand me, dear hıro.
we know something.
I can not make up mind to anyone..
I do not.
you can not give us reason.
off topic.
HaHAHAHHAAAAAAAAAAAAAA
@hamsterman: ok, agreed. I haven't tested the code - anyway, when having a vector class it is much simpler to understand what the code does, just because of the DRY principle and separation of concerns. It is not easy to understand what is going on if you construct the result by direct application of low level funtions (like sqrt).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class Vector2 {
public:
double x;
double y;
double length() { return sqrt(x * x + y * y); }
Vector2(double ax, double ay): x(ax), y(ay) { }
Vector2 operator- (const Vector2& v) { return Vector2(x - v.x, y - v.y); }
Vector2 normalized() { double l = length(); return Vector2(x / l, y / l); }
doubleoperator* (const Vector2& v) { return x * v.x + y * v.y; }
};
Vector2 a(x1, y1); // x1, y1 read from user input
Vector2 b(x2, y2); // x2, y2 read from user input
Vector2 c(x3, y3); // x3, y3 read from user input
double angle1 = acos(((a-b)*(a-c)).normalized());
double angle2 = acos(((b-a)*(b-c)).normalized());
double angle3 = acos(((c-a)*(c-b)).normalized());