def drawToAnimation(self): """ Draw. Assuming that the human is standing. Parameters ---------- """ listPlanes = [] if self.chair and self.table: listPlanes.append(self.chair.getPartition(Ps=1)) listPlanes.append(self.table.getPartition(Ps=1)) listPlanes = list(flatten(listPlanes)) alphas = [1 for plane in listPlanes] fig, ax = draw(xlim=[0, self.room.L], ylim=[0, self.room.W], zlim=[0, self.room.H], planes=listPlanes, enablevect=False, alphas=alphas) fig, ax = draw(figure=fig, axes=ax, vectors=[self.led], colors='blue') return fig, ax
def draw(self, displayRoom=False, displayReflectivity=False): """ Draw. Parameters ---------- displayRoom: bool displayReflectivity: bool """ if displayRoom: if displayReflectivity: alphas = [ 0.5 * plane.reflectivity for plane in self.listPlanes ] else: alphas = [1 for plane in self.listPlanes] fig, ax = draw(xlim=[0, self.room.L], ylim=[0, self.room.W], zlim=[0, self.room.H], planes=self.listPlanes, vectors=Vector(coord=self.human.normalVect, refPoint=self.human.ctrPoint, which='cartesian'), enablevect=False, alphas=alphas) else: listPlanes = [] listPlanes.append(self.human.listPlanes) if self.chair and self.table: listPlanes.append(self.chair.getPartition(Ps=1)) listPlanes.append(self.table.getPartition(Ps=1)) listPlanes = list(flatten(listPlanes)) if displayReflectivity: alphas = [0.5 * plane.reflectivity for plane in listPlanes] else: alphas = [1 for plane in listPlanes] fig, ax = draw(xlim=[0, self.room.L], ylim=[0, self.room.W], zlim=[0, self.room.H], planes=listPlanes, vectors=Vector(coord=self.human.normalVect, refPoint=self.human.ctrPoint, which='cartesian'), enablevect=False, alphas=alphas) fig, ax = draw(figure=fig, axes=ax, circles=[self.human.pd, self.pd], scales=5e3, vectors=[self.human.led, self.led]) return fig, ax
def draw(self): fig, ax = draw(cubes=[self.head, self.body, self.leg], xlim=[0, 3], ylim=[0, 3], zlim=[0, 3], lengths=0, enablevect='False') fig, ax = draw(figure=fig, axes=ax, vectors=Vector(coord=self.normalVect, refPoint=self.ctrPoint, which='cartesian'))
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.bases.vector_py import Vector_py as Vector from owcsimpy.geoobjects.bases.rectplane_py import RectPlane_py as RectPlane from owcsimpy.geoutils.draw import draw # Original position polar, az, Rod = 90, -90, 30 # polar, azimuth, Rodrigues translation = 0.5 v = Vector(np.array([1, np.deg2rad(polar), np.deg2rad(az)])) ctrPoint = np.array(3 * [translation]) plane = RectPlane(normalVect=v, ctrPoint=ctrPoint, RodriguesAngle=np.deg2rad(Rod), dimensions=[2, 1]) subplanes = plane.getPartition(2) fig, ax = draw(planes=subplanes, xlim=[-2, 2], ylim=[-2, 2], zlim=[-2, 2]) # For reference draw(figure=fig, axes=ax, planes=plane, facecolors='black', colors='black') plt.show()
normalVect = Vector(np.array([1, np.deg2rad(90), np.deg2rad(180)]), which='spherical') ctrPoint = np.array([5, 2, 3]) planes.append( RectPlane(normalVect, ctrPoint=ctrPoint, RodriguesAngle=np.deg2rad(0), dimensions=[1.7, 1])) # Prepare canvases fig, axs = draw(subplots=True, figsize=(14, 6), nrows=1, ncols=3, xlim=[0, 5], ylim=[0, 5], zlim=[0, 3], azim=-32, elev=25) for idx in range(2, 5): colors = ['red', 'red', 'black'] fig, axs[idx - 2] = draw(figure=fig, axes=axs[idx - 2], planes=[planes[0], planes[1], planes[idx]], colors=colors, facecolors=colors) ray = np.append(planes[0].ctrPoint, planes[1].ctrPoint).reshape(2, -1)
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.models.baredetector_py import BareDetector_py as BareDetector from owcsimpy.geoutils.draw import draw # >>> pd = BareDetector(np.deg2rad(45), np.deg2rad(30), np.array([1, 2, 0]), area=1e-4) # >>> draw(circles=pd, scales=5e3, xlim=[0, 5], ylim=[0, 4], zlim=[0, 3]) # >>> plt.show()
v = Vector(np.array([1, np.deg2rad(polar), np.deg2rad(az)])) ctrPoint = np.array(3 * [translation]) plane = RectPlane(normalVect=v, ctrPoint=ctrPoint, RodriguesAngle=np.deg2rad(Rod), dimensions=[2, 1]) return plane # Will draw 4 different canvases fig, axs = draw(subplots=True, figsize=(14, 6), nrows=1, ncols=4, xlim=[-2, 2], ylim=[-2, 2], zlim=[-2, 2]) # Original position polar, az, Rod = 0, 0, 0 # polar, azimuth, Rodrigues translation = 0 plane = genPlane(polar, az, Rod, translation) fig, axs[0] = draw(figure=fig, axes=axs[0], planes=plane, colors='blue', facecolors='blue') axs[0].set_title("angles=({},{},{}), x=y=z={}".format(polar, az, Rod,
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.bases.vector_py import Vector_py as Vector from owcsimpy.geoobjects.bases.circle_py import Circle_py as Circle from owcsimpy.geoutils.draw import draw normalVect = Vector(np.array([1, np.deg2rad(30), np.deg2rad(45)])) ctrPoint = 0.5 * np.ones(3) circle = Circle(normalVect, ctrPoint, radius=0.25) fig, ax = draw(circles=circle, figsize=(5, 6)) plt.show()
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.bases.vector_py import Vector_py as Vector from owcsimpy.geoobjects.bases.rectplane_py import RectPlane_py as RectPlane from owcsimpy.geoutils.draw import draw # Prepare a canvas fig, ax = draw(xlim=[-2, 2], ylim=[-2, 2], zlim=[-2, 2]) v = Vector(np.array([1, np.deg2rad(90), np.deg2rad(90)])) plane = RectPlane(normalVect=v, ctrPoint=np.zeros(3), dimensions=[2, 1]) fig, ax = draw(figure=fig, axes=ax, planes=plane, facecolors='black', colors='black') plane = plane.rotate(np.deg2rad(45), plane.normalVect) fig, ax = draw(figure=fig, axes=ax, planes=plane, facecolors='red', colors='red')
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.bases.vector_py import Vector_py as Vector from owcsimpy.geoobjects.bases.cube_py import Cube_py as Cube from owcsimpy.geoutils.draw import draw cube = Cube(Vector(np.array([1, np.deg2rad(90), np.deg2rad(90)])), ctrPoint=np.array([0.5, 0.5, 0.5]), dimensions=[2, 1, 1], RodriguesAngle=np.deg2rad(30)) planes = cube.getPartition(delta=0.5) fig, ax = draw(planes=planes, alphas=0.2, xlim=[-2, 2], ylim=[-2, 2], zlim=[-2, 2]) plt.show()
import numpy as np import matplotlib.pyplot as plt from owcsimpy.geoutils.draw import draw from owcsimpy.geoobjects.bases.vector_py import Vector_py as Vector r = 0.5 polar = np.deg2rad(45) azimuth = np.deg2rad(25) v1 = Vector(np.array([r, polar, azimuth]), refPoint=np.array([0.25, 0.25, 0]), which='spherical') # Normalize length and rotate v2 = v1.normalize().rotate(theta=np.deg2rad(30), refVector=np.array([0, 0, 1])) # Translate v3 = v1.translate(v1.refPoint + np.array([0, 0, 0.5])) # Draw fig, ax = draw(vectors=[v1, v2, v3], colors=['black', 'red', 'blue'], figsize=(5, 6)) plt.show() import matplotlib.pyplot as plt
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.models.pointsource_py import PointSource_py as PointSource from owcsimpy.geoutils.draw import draw # >>> led = PointSource(np.pi,0,np.array([2.5,2,3])) # >>> draw(vectors=led,xlim=[0,5],ylim=[0,4],zlim=[0,3]) # >>> plt.show()
import numpy as np import matplotlib.pyplot as plt from owcsimpy.geoutils.draw import draw from owcsimpy.geoobjects.bases.paramline_py import ParamLine_py as Line # Generate a line l l = Line(np.array([0.5, 0.5, 0.5]), np.ones(3)) # Draw fig, ax = draw(lines=l, figsize=(5, 6)) # Get a point at t = 0.25 P = l.getPoint(0.25) print("Point at t=0.25 is {}".format(P)) # Draw x, y, z = P ax.scatter(x, y, z) plt.show()
import numpy as np from owcsimpy.geoobjects.models.humancube_py import HumanCube_py as Human from owcsimpy.geoutils.draw import draw rho_keys = ['shirt', 'hair'] rho_vals = [0.3, 0.6] reflectivities = {rho_keys[i]: rho_vals[i] for i in range(2)} persons = [] persons.append( Human(direction=np.deg2rad(45), loc=np.array([2, 2]), dimensions=[0.3, 0.5, 1.7], identity=2, reflectivities=reflectivities)) persons.append( Human(direction=np.deg2rad(180), loc=np.array([4, 1]), dimensions=[0.3, 0.5, 1.7], identity=2, reflectivities=reflectivities)) draw(models3d=persons, xlim=[0, 5], ylim=[0, 4], zlim=[0, 3], facecolors=['red', 'blue'], colors=['red', 'blue']) # >>> plt.show()
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.models.humancubes_py import HumanCubes_py as Human from owcsimpy.geoutils.draw import draw person = Human(np.array([1, 1]), np.deg2rad(30), reflectivities={ 'hair': 0.7, 'face': 0.5, 'shirt': 0.3 }) draw(models3d=person, figsize=(6, 6), azim=-100, elev=25, xlim=[0, 3], ylim=[0, 3], zlim=[0, 3]) plt.show()
import matplotlib.pyplot as plt import numpy as np from owcsimpy.geoobjects.models.roomcube_py import RoomCube_py as Room from owcsimpy.geoutils.draw import draw rho_keys = ['b', 't', 's', 'n', 'e', 'w'] rho_vals = [0.1, 0.5, 0.5, 0.5, 0.5, 0.5] reflectivities = {rho_keys[i]: rho_vals[i] for i in range(6)} fig, axs = draw(subplots=True, nrows=1, ncols=2, figsize=(14, 8), xlim=[0, 5], ylim=[0, 4], zlim=[0, 3]) room = Room(dimensions=[5, 4, 3], identity=1, reflectivities=reflectivities) # Partition with the delta of 1 m subplanes = room.getPartition(delta=1) fig, axs[0] = draw(figure=fig, axes=axs[0], models3d=room) fig, axs[1] = draw(figure=fig, axes=axs[1], planes=subplanes, xlim=[0, 5], ylim=[0, 4], zlim=[0, 3], alphas=[0.5 * plane.reflectivity for plane in subplanes],