Example #1
0
def lireGrapheNavigation(nomFichier):
    gr = Graphe(oriente=False)
    f = open(nomFichier, "r")

    for ligne in f:
        mots = ligne.split()
        if len(mots) > 0:
            if mots[0] == '#':
                pass
            elif mots[0] == 's':
                nom = mots[1]
                x = float(mots[3])
                y = float(mots[4])
                z = float(mots[5])
                gr.ajouterSommet(nom, vec3.Vec3((x, y, z)))
            elif mots[0] == 'a':
                ori = mots[1]
                ext = mots[2]
                p1 = gr.etiquette(ori)
                p2 = gr.etiquette(ext)
                dist = p1.distance(p2)
                gr.ajouterArc(ori, ext, dist)

    f.close()

    return gr
Example #2
0
def computeZipinNormal(grooveTheta, side, wo):
    #if grooveTheta > math.pi * .5:
    #    print('error!')
    n = vec3.Vec3(math.cos(grooveTheta), 0, math.sin(grooveTheta))
    #feng comment please why the sign works the way it does
    #will this have impact when wo.y != 0 
    n.x *= math.copysign(1, wo.x) 
    if side == 'right':
        n.x *= -1
    return n
Example #3
0
 def computeRotation(self):
     self.phi = math.atan2(self.wh.y, self.wh.x)
     #print(math.degrees(self.phi))
     
     gamma = -self.phi
     sinGamma = math.sin(gamma)
     cosGamma = math.cos(gamma)
     self.rotation = []
     self.rotation.append(vec3.Vec3(cosGamma, -sinGamma, 0))
     self.rotation.append(vec3.Vec3(sinGamma, cosGamma, 0))
     self.rotation.append(vec3.Vec3(0, 0, 1))
     self.inverse = []
     self.inverse.append(vec3.Vec3(cosGamma, sinGamma, 0))
     self.inverse.append(vec3.Vec3(-sinGamma, cosGamma, 0))
     self.inverse.append(vec3.Vec3(0, 0, 1))
Example #4
0
def makeVector(theta, phi):
    sinTheta = math.sin(theta)
    cosTheta = math.cos(theta)
    sinPhi = math.sin(phi)
    cosPhi = math.cos(phi)
    return vec3.Vec3(sinTheta * cosPhi, sinTheta * sinPhi, cosTheta)
Example #5
0
def multiply(rotation, w):
    x = vec3.dot(rotation[0], w)
    y = vec3.dot(rotation[1], w)
    z = vec3.dot(rotation[2], w)
    return vec3.Vec3(x, y, z) 
Example #6
0
def SphericalDirection(sinTheta, cosTheta, phi):
    return vec3.Vec3(sinTheta * math.cos(phi), sinTheta * math.sin(phi),
                     cosTheta)