// 視点+正規視線ベクトル*係数 で交点を求める
// この時、視線ベクトルではなく、平面の法線*-1を用いれば平面との最短距離を求められる
function CalcCrossPos( $p1, $eye, $pos ) {
// 係数tの求め方
// a(pos.x+t*eye.x) + b(pos.y+t*eye.y) + c(pos.z+t*eye.z) + d = 0;
// a*pos.x + a*t*eye.x + b*pos.y + b*t*eye.y + c*pos.z + c*t*eye.z + d = 0;
// t( a*eye.x + b*eye.y + c*eye.z ) = -1 * ( a*pos.x + b*pos.y + c*pos.z + d);
// t = ( -1 * ( a*pos.x + b*pos.y + c*pos.z + d ) ) / ( a*eye.x + b*eye.y + c*eye.z );
// この時、視線ベクトルではなく、平面の法線*-1を用いれば平面との最短距離を求められる
function CalcCrossPos( $p1, $eye, $pos ) {
// 係数tの求め方
// a(pos.x+t*eye.x) + b(pos.y+t*eye.y) + c(pos.z+t*eye.z) + d = 0;
// a*pos.x + a*t*eye.x + b*pos.y + b*t*eye.y + c*pos.z + c*t*eye.z + d = 0;
// t( a*eye.x + b*eye.y + c*eye.z ) = -1 * ( a*pos.x + b*pos.y + c*pos.z + d);
// t = ( -1 * ( a*pos.x + b*pos.y + c*pos.z + d ) ) / ( a*eye.x + b*eye.y + c*eye.z );
$t = ( -1 * ( ( $p1->a * $pos->x ) + ( $p1->b * $pos->y ) + ( $p1->c * $pos->z ) + $p1->d ) ) / ( ( $p1->a * $eye->x ) + ( $p1->b * $eye->y ) + ( $p1->c * $eye->z ) );
$temp = Vec3Scale( $eye, $t );
$temp = Vec3Add( $pos, $temp );
}