+ 1
How can I use * instead of pow?
When I run the commented part instead of the other part I get an error "expected ) before ; token ; " float ds = (sqrt(pow((p.getX() - getX()),2) + pow((p.getY()- getY()),2) + pow((p.getZ() - getZ()),2))); /* float ds=sqrt (((p.getX()-getX())*(p.getX()-getX())+ ((p.getY()-getY())*(p.getY()-getY())+ ((p.getZ()-getZ())*(p.getZ()-getZ())); */
2 Réponses
+ 1
Remove the first parenthesis '(' from each line
They are mismatched and you don't need them
+ 1
To not confuse, simplifying to understand :
float x, y, z;
x = p.getX()-getX();
y = p.getY()-getY();
z = p.getZ()-getZ();
float ds = sqrt( pow(x,2) + pow(y,2) + pow(z,2) );
/*
float ds=sqrt( (x*x)+(y*y)+(z*z) );
*/