public FRay(FVec3 origin, FVec3 direction) { this.origin = origin; this.direction = FVec3.Normalize(direction); }
public bool IntersectRaySphere(FVec3 sphereCenter, Fix64 radius, out FVec3 point1, out FVec3 point2, out FVec3 normal1, out FVec3 normal2) { FVec3 d = this.origin - sphereCenter; Fix64 a = this.direction.Dot(this.direction); Fix64 b = d.Dot(this.direction); Fix64 c = d.Dot() - radius * radius; Fix64 disc = b * b - a * c; if (disc < Fix64.Zero) { point1 = this.origin; point2 = this.origin; normal1 = FVec3.zero; normal2 = FVec3.zero; return(false); } Fix64 sqrtDisc = Fix64.Sqrt(disc); Fix64 invA = Fix64.One / a; Fix64 t1 = (-b - sqrtDisc) * invA; Fix64 t2 = (-b + sqrtDisc) * invA; Fix64 invRadius = Fix64.One / radius; point1 = this.origin + t1 * this.direction; point2 = this.origin + t2 * this.direction; normal1 = (point1 - sphereCenter) * invRadius; normal2 = (point2 - sphereCenter) * invRadius; return(true); }
public FLine3 Inersect(FLine3 line) { FVec3 vector = this.point1 - line.point1, vector2 = line.point2 - line.point1, vector3 = this.point2 - this.point1; Fix64 dot1 = vector.Dot(vector2); Fix64 dot2 = vector2.Dot(vector3); Fix64 dot3 = vector.Dot(vector3); Fix64 dot4 = vector2.Dot(); Fix64 dot5 = vector3.Dot(); Fix64 mul1 = (dot1 * dot2 - dot3 * dot4) / (dot5 * dot4 - dot2 * dot2); Fix64 mul2 = (dot1 + dot2 * mul1) / dot4; return(new FLine3(this.point1 + mul1 * vector3, line.point1 + mul2 * vector2)); }
public FSphere(FVec3 center, Fix64 radius) { this.center = center; this.radius = radius; }
public FLine3(FVec3 point1, FVec3 point2) { this.point1 = point1; this.point2 = point2; }
public static void InersectPlane(ref FLine3 line, ref FVec3 planeNormal, ref FVec3 planeLocation, out FVec3 result) { Fix64 dot = -(planeNormal.x * planeLocation.x) - planeNormal.y * planeLocation.y - planeNormal.z * planeLocation.z; Fix64 dot3 = planeNormal.x * (line.point2.x - line.point1.x) + planeNormal.y * (line.point2.y - line.point1.y) + planeNormal.z * (line.point2.z - line.point1.z); Fix64 dot2 = -((dot + planeNormal.x * line.point1.x + planeNormal.y * line.point1.y + planeNormal.z * line.point1.z) / dot3); result = line.point1 + dot2 * (line.point2 - line.point1); }
public void HandleBeginMove(string rid, FVec3 direction) { Champion entity = this._entityManager.GetChampion(rid); entity.BeginMove(direction); }
public static FMat4 FromEuler(FVec3 euler) { return(FromEuler(euler.x, euler.x, euler.z)); }
public static FMat4 FromScale(FVec3 scale) { return(FromScale(scale.x, scale.y, scale.z)); }
public static FMat4 FromRotationAxis(Fix64 angle, FVec3 axis) { FQuat quaternion = FQuat.AngleAxis(angle, axis); return(FromQuaternion(quaternion)); }
public FMat3(FVec3 x, FVec3 y, FVec3 z) { this.x = x; this.y = y; this.z = z; }