source: framspy/gui/framsutils/utils.py @ 1320

Last change on this file since 1320 was 1198, checked in by Maciej Komosinski, 22 months ago

Added simple Python GUI for Framsticks library/server

File size: 712 bytes
Line 
1import glm
2
3def parseNeuronDToOrient(d: str) -> glm.mat4:
4    ix = d.find(':')
5    rorient = glm.mat4(1)
6    if ix != -1:
7        ds = d[ix+1:].split(',')
8        ds = [x.split('=') for x in ds]
9        rots = [x for x in ds if x[0].startswith('r')]
10
11        if not any("ry" in x[0] for x in rots):
12            rots.append(["ry", '0'])
13        if not any("rz" in x[0] for x in rots):
14            rots.append(["rz", '0'])
15
16        angle = next(float(x[1]) for x in rots if x[0] == "rz")
17        rorient = glm.rotate(rorient, angle, glm.vec3(0,0,1))
18        angle = -next(float(x[1]) for x in rots if x[0] == "ry")
19        rorient = glm.rotate(rorient, angle, glm.vec3(0,1,0))
20    return rorient
Note: See TracBrowser for help on using the repository browser.