Flex Flash 求一点关于直线的对称点

/**
 * 求一点关于直线的对称点
 * 
 * @date 2012-08-25
 * @author Lycoris
 **/
public function symmetricalPoint(p:Point,  start:Point, end:Point) : Point{
	var s:Point = new Point;
	try{
		var A:Number;
		var B:Number;
		var C:Number;
		A=end.y-start.y;
		B=start.x-end.x;
		C=(end.x-start.x) * start.y - (end.y-start.y) * start.x;
		var tmp:Number = A * A + B * B;
		s.x = (B*B*p.x - A*A*p.x - 2*A*B*p.y - 2*A*C) / tmp;
		s.y = (A*A*p.y - B*B*p.y - 2*A*B*p.x - 2*B*C) / tmp;
	}
	catch(e:Error){
		Alert.show(e.message);
	}
	return s;
}

你可能感兴趣的:(Flash)