Exemplo n.º 1
0
 def CalcEffectiveRadius(self, direction, planetPosition, planetRadius):
     distToMiddle = geo2.Vec3DotD(planetPosition, direction)
     if distToMiddle < 0:
         return None
     midPoint = geo2.Vec3ScaleD(direction, distToMiddle)
     distToCenter = geo2.Vec3DistanceD(planetPosition, midPoint)
     if distToCenter > planetRadius:
         return None
     return sqrt(planetRadius * planetRadius - distToCenter * distToCenter)
Exemplo n.º 2
0
 def CalcEffectiveRadius(self, direction, planetPosition, planetRadius):
     """
     Effective radius is half the distance through the planet along
     the ray of intersection(direction).
     Assumes player ship is at (0,0,0)
     direction - normalized direction
     """
     distToMiddle = geo2.Vec3DotD(planetPosition, direction)
     if distToMiddle < 0:
         return None
     midPoint = geo2.Vec3ScaleD(direction, distToMiddle)
     distToCenter = geo2.Vec3DistanceD(planetPosition, midPoint)
     if distToCenter > planetRadius:
         return None
     return sqrt(planetRadius * planetRadius - distToCenter * distToCenter)
Exemplo n.º 3
0
    def FindNextCollision(self, destination, candidates, popCollision=True):
        minDist = None
        time = blue.os.GetSimTime()
        position = self.shipBall.GetVectorAt(blue.os.GetSimTime())
        position = (position.x, position.y, position.z)
        nextCollision = None
        for each in candidates:
            collisionBall = each[0]
            collisionCenter = collisionBall.GetVectorAt(time)
            collisionCenter = (collisionCenter.x, collisionCenter.y,
                               collisionCenter.z)
            projection = geo2.Vec3DotD(collisionCenter, self.normDirection)
            if minDist is None or projection < minDist:
                minDist = projection
                nextCollision = each

        if nextCollision is not None and popCollision:
            candidates.remove(nextCollision)
        return nextCollision
Exemplo n.º 4
0
 def GetDistanceToTarget(self, direction, planetPosition):
     return geo2.Vec3DotD(planetPosition, direction)
Exemplo n.º 5
0
 def GetDistanceToTarget(self, direction, planetPosition):
     """
     Returns the distance to the point closest to planetPosition
     along the direction vector.
     """
     return geo2.Vec3DotD(planetPosition, direction)