コード例 #1
0
    def find_landing_orientation(car: Car) -> Mat33:

        # FIXME: This uses a cheap approximation of the walls to find landing orientation

        obj = DummyObject(car)
        prev_pos = obj.pos
        for i in range(100):
            predict.fall(obj, 0.1)

            # Checking for intersections
            for plane in Field.SIDE_WALLS_AND_GROUND:
                if intersects_plane(prev_pos, obj.pos, plane):
                    # Bingo!
                    fall_dir = normalize(obj.pos - prev_pos)
                    left = -cross(fall_dir, plane.normal)
                    forward = -cross(plane.normal, left)

                    return Mat33.from_columns(forward, left, plane.normal)

            prev_pos = obj.pos

        # No wall/ground intersections found in fall
        # Default to looking in direction of velocity, but upright

        forward = normalize(xy(
            car.vel)) if norm(xy(car.vel)) > 20 else car.forward
        up = Vec3(z=1)
        left = cross(up, forward)

        return Mat33.from_columns(forward, left, up)
コード例 #2
0
    def find_landing_orientation(car: Car, num_points: int) -> Mat33:
        """
        dummy = DummyObject(car)
        trajectory = [Vec3(dummy.pos)]

        for i in range(0, num_points):
            fall(dummy, 0.0333)  # Apply physics and let car fall through the air
            trajectory.append(Vec3(dummy.pos))
            up = dummy.pitch_surface_normal()
            if norm(up) > 0.0 and i > 10:
                up = normalize(up)
                forward = normalize(dummy.vel - dot(dummy.vel, up) * up)
                left = cross(up, forward)

                return Mat33.from_columns(forward, left, up)

        return Mat33(car.rot)
        """

        forward = normalize(xy(
            car.vel)) if norm(xy(car.vel)) > 20 else car.forward
        up = Vec3(z=1)
        left = cross(up, forward)

        return Mat33.from_columns(forward, left, up)
コード例 #3
0
    def find_landing_orientation(car: Car) -> Mat33:

        # FIXME: If we knew the arena's mesh we could test if we are landing on a wall or something

        forward = normalize(xy(
            car.vel)) if norm(xy(car.vel)) > 20 else car.forward
        up = Vec3(z=1)
        left = cross(up, forward)

        return Mat33.from_columns(forward, left, up)
コード例 #4
0
    def find_landing_orientation(car: Car, num_points: int) -> Mat33:
        dummy = DummyObject(car)

        for i in range(0, num_points):
            fall(dummy,
                 0.0333)  # Apply physics and let car fall through the air

            if i > 5 and sdf_contains(dummy.pos):
                up = normalize(sdf_normal(dummy.pos))
                left = cross(normalize(dummy.vel), up)
                forward = cross(up, left)

                return Mat33.from_columns(forward, left, up)

        forward = normalize(xy(
            car.vel)) if norm(xy(car.vel)) > 20 else car.forward
        up = Vec3(z=1)
        left = cross(up, forward)

        return Mat33.from_columns(forward, left, up)