//double sqrt(double x) //{ // float y; // float delta; // float maxError; // if (x <= 0) // { // return 0; // } // // initial guess // y = x / 2; // // refine // maxError = x * 0.001; // do // { // delta = (y * y) - x; // y -= delta / (2 * y); // } while (delta > maxError || delta < -maxError); // return y; //} public static IntVector2 MoveAngle(IntVector2 fromPos, short angle, int distant) { IntegerFloat sinValue = SinFuncByTable.SinAngle(angle); IntegerFloat cosValue = CosFuncByTable.CosAngle(angle); return(new IntVector2(fromPos.x + (cosValue * distant).ToInt(), fromPos.y + (sinValue * distant).ToInt())); }
public static IntVector2 Rotate(IntVector2 pointPos, short angle) { IntVector2 ret = pointPos; IntegerFloat cosFloat = CosFuncByTable.CosAngle(angle); IntegerFloat sinFloat = SinFuncByTable.SinAngle(angle); ret.x = (cosFloat * pointPos.x).ToInt() - (sinFloat * pointPos.y).ToInt(); ret.y = (sinFloat * pointPos.x).ToInt() + (cosFloat * pointPos.y).ToInt(); return(ret); }