Пример #1
0
	def to_matrix(self):
		point_matrix = matrix.zeros_matrix(1,4)
		point_matrix[0,0] = self.x
		point_matrix[1,0] = self.y
		point_matrix[2,0] = self.z
		point_matrix[3,0] = 1.0
		return point_matrix
Пример #2
0
def points_to_pixel_map_old(points, lower_bound_x, lower_bound_y, upper_bound_x, upper_bound_y):
	#Allocate a blank 2d matrix to serve as the pixel map
	#Pixel map is sized according to view window
	#Columns = X size, Rows = Y size
	xdim = upper_bound_x-lower_bound_x+1
	ydim = upper_bound_y-lower_bound_y+1
	pixel_map = matrix.zeros_matrix(xdim,ydim)

	#Loop over each point
	for point in points:
		#World
		world_x = point.x
		world_y = point.y
		#Pixel map
		pixel_x = int( world_x - lower_bound_x ) - 1
		pixel_y = int( upper_bound_y - world_y ) - 1
				
		#Cheap check...bleh
		if(pixel_x < 0):
			pixel_x = 0
		if(pixel_y < 0):
			pixel_y = 0
		
		#Write something... a 1?
		pixel_map[pixel_y,pixel_x] = 1.0

	return pixel_map
Пример #3
0
def points_to_pixel_map_old(points, xdim, ydim):
	#Allocate a blank 2d matrix to serve as the pixel map
	#Pixel map is sized according to given image size
	#Columns = X size, Rows = Y size
	pixel_map = matrix.zeros_matrix(xdim,ydim)
	
	#Init matrix to xpm background color
	rows,columns = pixel_map.shape
	width = columns;
	height = rows;
	for row in range(0,height): #Y
		for col in range(0,width): #X
				pixel_map[row,col] = xpm.BACKGROUND_FP_VAL
	
	#Loop over each point
	for point in points:
		#World
		world_x = point.x
		world_y = point.y
		#Pixel map
		lower_bound_x = 0 #Always zero?
		upper_bound_y = ydim-1
		pixel_x = int( world_x - lower_bound_x ) - 1
		pixel_y = int( upper_bound_y - world_y ) - 1
				
		#Cheap check...bleh
		if(pixel_x < 0):
			pixel_x = 0
		if(pixel_y < 0):
			pixel_y = 0
		
		#Write something... a 1?
		pixel_map[pixel_y,pixel_x] = xpm.W_OFFSET

	return pixel_map
Пример #4
0
def points_to_pixel_map(points, xdim, ydim):
	#Allocate a blank 2d matrix to serve as the pixel map
	#Pixel map is sized according to given image size
	#Columns = X size, Rows = Y size
	pixel_map = matrix.zeros_matrix(xdim,ydim)

	#Loop over each point
	for point in points:
		#World
		world_x = point.x
		world_y = point.y
		#Pixel map
		lower_bound_x = 0 #Always zero?
		upper_bound_y = ydim-1
		pixel_x = int( world_x - lower_bound_x ) - 1
		pixel_y = int( upper_bound_y - world_y ) - 1
				
		#Cheap check...bleh
		if(pixel_x < 0):
			pixel_x = 0
		if(pixel_y < 0):
			pixel_y = 0
		
		#Write something... a 1?
		pixel_map[pixel_y,pixel_x] = 1.0

	return pixel_map
Пример #5
0
def geometric_objects_to_pixel_map(geometric_object_index_to_points,geometric_objects, xdim, ydim, front_clip_value):
	#Try to copy code from slides
	#Allocate the frame and z buffers
	F = matrix.zeros_matrix(xdim,ydim)
	Z = matrix.zeros_matrix(xdim,ydim)
	#Fill in background and -1 for Z
	rows,columns = F.shape
	width = columns;
	height = rows;
	for row in range(0,height): #Y - row
		for col in range(0,width): #X - col
			F[row,col] = xpm.BACKGROUND_FP_VAL
			Z[row,col] = -1.0
	
	#~ #Get min and max z values
	#~ minz = 999
	#~ maxz = -999
	#~ for idx in geometric_object_index_to_points:
		#~ poly = geometric_objects[idx]
		#~ points = geometric_object_index_to_points[idx]
		#~ #For each point in poly projection
		#~ for point in points:
			#~ pz = poly.get_z_at_xy(point.x,point.y)
			#~ 
			#~ if pz < minz and pz >= -1.0:
				#~ minz = pz
			#~ if pz > maxz and pz <= 1.0:
				#~ maxz = pz
				#~ 
	#~ print "minz",minz
	#~ print "maxz",maxz
	
	#For each poly
	for idx in geometric_object_index_to_points:
		poly = geometric_objects[idx]
		points = geometric_object_index_to_points[idx]
		#For each point in poly projection
		for point in points:
			#World coords
			world_x = point.x
			world_y = point.y
			#Pixel map coords
			lower_bound_x = 0 #Always zero?
			upper_bound_y = ydim-1
			pixel_x = int( world_x - lower_bound_x ) - 1
			pixel_y = int( upper_bound_y - world_y ) - 1
					
			#Cheap check
			if(pixel_x < 0):
				pixel_x = 0
			if(pixel_y < 0):
				pixel_y = 0
			
			#Address as [pixel_y,pixel_x]
			#Ask poly for z val at this pixels xy
			pz = poly.get_z_at_xy(point.x,point.y)
			if (pz < front_clip_value) and (pz > Z[pixel_y,pixel_x]):
				Z[pixel_y,pixel_x] = pz
				F[pixel_y,pixel_x] = poly.get_xpm_fp_color_at_xy(point.x,point.y)
			
	#Return frame buffer (pixel map)
	return F