예제 #1
0
    def __init__(self, center, scale, orient):
        self.center = center
        self.scale = scale
        self.orient = orient

        self.volume = 4.0 / 3.0 * np.pi * 4.0**2 * (self.scale)**3 * 1.5 * 1.03
        self.generateKeyPoints()
        self.curvedVessel = CurvedVessel(R1=R1)
예제 #2
0
class Ellipsoid:
    def __init__(self, center, scale, orient):
        self.center = center
        self.scale = scale
        self.orient = orient

        self.volume = 4.0 / 3.0 * np.pi * 4.0**2 * (self.scale)**3 * 1.5 * 1.03
        self.generateKeyPoints()
        self.curvedVessel = CurvedVessel(R1=R1)

    def generateKeyPoints(self):
        a = 1.5 * self.scale
        b = 4.0 * self.scale
        c = 4.0 * self.scale

        theta = np.linspace(0, np.pi, 20)
        phi = np.linspace(0, 2 * np.pi, 40)
        Theta, Phi = np.meshgrid(theta, phi)

        self.keyPoints = np.array([(a * np.sin(Theta) * np.cos(Phi)).flatten(),
                                   (b * np.sin(Theta) * np.sin(Phi)).flatten(),
                                   (c * np.cos(Theta)).flatten()]).T
        phi = math.atan2(self.orient[1], self.orient[0])
        orientVec2 = np.array([-math.sin(phi), math.cos(phi), 0])
        orientVec3 = np.cross(self.orient, orientVec2)
        localFrame = np.array([self.orient, orientVec2, orientVec3])
        keyPoints_rot = np.transpose(np.dot(localFrame, self.keyPoints.T))

        self.keyPoints = keyPoints_rot + self.center

    def move(self):
        self.posMove = np.random.randn(3)
        self.orientMove = np.random.randn(3) * 0.5

        self.center_old = self.center.copy()
        self.orient_old = self.orient.copy()
        self.center += self.posMove
        self.orient += self.orientMove
        self.orient /= np.linalg.norm(self.orient)

        self.generateKeyPoints()

    def moveBack(self):
        self.center = self.center_old
        self.orient = self.orient_old

        self.generateKeyPoints()

    def isOverlap(self, second):
        dist = euclidean_distances(self.keyPoints, second.keyPoints)
        dist[dist == 0] = 100
        if np.any(dist < thresh):
            return True
        else:
            return False

    def isInTube(self):
        return not np.any(self.curvedVessel.isOutsideVec(self.keyPoints))
예제 #3
0
    def resetMap(self):

        index = np.random.choice(self.numMaps, 1, p=self.multiMapProbs)[0]
        self.obstacles, self.obstacleCenters = self.obstaclesList[index], self.obstaclesCentersList[index]
        self.wallHeight, self.wallRadius = self.wallHeights[index], self.wallRadii[index]

        if self.multiMapNames[index] in self.config:
            self.curvedVessel = CurvedVessel(**self.config[self.multiMapNames[index]])
            print('construct curved vessels', self.multiMapNames[index])
        else:
            self.curvedVessel = None

        print('reset map', self.multiMapNames[index], self.wallHeight, self.wallRadius)

        if self.RBCInitialMoveFlag and self.epiCount % self.RBCInitialMoveFreq == 0:
            self.RBCConstructAndMove(self.RBCInitialMoveSteps)
예제 #4
0
config['currentState'] = [-20, -20, 1, 1, 0, 0]
config['currentState'] = [0, 0, 1, 1, 0, 0]
config['targetState'] = [15, 15, 25]
config['filetag'] = 'Traj/test'
config['trajOutputFlag'] = True
config['trajOutputInterval'] = 100
config['finishThresh'] = 2
config['gravity'] = 0
config['multiMapNames'] = ['config_RBC_CV_R15_5PerTest.json']
config['multiMapProbs'] = [1.0]

with open('config_test.json', 'w') as f:
    json.dump(config, f)


cv = CurvedVessel(R1 = 15)
agent.env = ActiveParticle3DEnv('config_test.json',1, obstacleConstructorCallBack, cv)


finalTarget = [0, 0, 499]

nTraj = 5
endStep = 500

recorder = []

guide = PathGuiderCurvedVessel(R1=15)

for i in range(nTraj):
    print(i)
    guide.reset()
예제 #5
0
config['dynamicTargetFlag'] = False
config['currentState'] = [-20, -20, 1, 1, 0, 0]
config['currentState'] = [0, 0, 1, 1, 0, 0]
config['targetState'] = [15, 15, 25]
config['filetag'] = 'Traj/test'
config['trajOutputFlag'] = True
config['trajOutputInterval'] = 100
config['finishThresh'] = 2
config['gravity'] = 0
config['multiMapNames'] = ['config_RBC_CV_R5_10PerTest.json']
config['multiMapProbs'] = [1.0]

with open('config_test.json', 'w') as f:
    json.dump(config, f)

cv = CurvedVessel(R1=5)
agent.env = ActiveParticle3DEnv('config_test.json', 1,
                                obstacleConstructorCallBack, cv)

finalTarget = [0, 0, 499]

nTraj = 5
endStep = 800

recorder = []

guide = PathGuiderCurvedVessel(R1=5)

for i in range(nTraj):
    print(i)
    guide.reset()