Esempio n. 1
0
def transform_objects(objects, scale,rotation_cc, trans_x, trans_y, trans_z=0):
	#Construct transform matrices
	#Scale
	scale_matrix = matrix.identity_matrix(4,4)
	scale_matrix[0,0] = scale
	scale_matrix[1,1] = scale
	scale_matrix[2,2] = scale
	#Rotation (around Z axis)
	rads = rotation_cc * (math.pi/180.0)
	rotation_matrix = matrix.identity_matrix(4,4)
	rotation_matrix[0,0] = math.cos(rads)
	rotation_matrix[1,0] = math.sin(rads) 
	rotation_matrix[0,1] = -1 * math.sin(rads)
	rotation_matrix[1,1] = math.cos(rads)
	#Translation
	translation_matrix = matrix.identity_matrix(4,4)
	translation_matrix[0,3] = trans_x
	translation_matrix[1,3] = trans_y
	translation_matrix[2,3] = trans_x
	
	#Multiply for one transform matrix
	transform_matrix = translation_matrix * (rotation_matrix * scale_matrix)
	
	#Loop over each geometric object
	for obj in objects:
		#Apply transform to each object
		obj.apply_transform(transform_matrix)
	
	#Return modified objects
	return objects
Esempio n. 2
0
def get_rotation_zaxis_matrix(rotation_cc):
	rads = rotation_cc * (math.pi/180.0)
	rotation_matrix = matrix.identity_matrix(4,4)
	rotation_matrix[0,0] = math.cos(rads)
	rotation_matrix[1,0] = math.sin(rads) 
	rotation_matrix[0,1] = -1 * math.sin(rads)
	rotation_matrix[1,1] = math.cos(rads)
	return rotation_matrix
Esempio n. 3
0
def get_shear_3d_matrix(umin, umax, vmin, vmax, prpu, prpv, prpn):
	#Calc shx and y values to fill in matrix
	shx = (0.5*(umax+umin) - prpu) / prpn
	shy = (0.5*(vmax+vmin) - prpv) / prpn
	
	#Populate 4D transform matrix
	m = matrix.identity_matrix(4,4)
	m[0,2] = shx
	m[1,2] = shy
	return m
Esempio n. 4
0
    def __init__(self, hsize, vsize, field_of_view):
        self.hsize = hsize
        self.vsize = vsize
        self.field_of_view = field_of_view
        self.transform = identity_matrix()

        # calculate pixel size
        half_view = tan(field_of_view / 2)
        aspect = hsize / vsize
        if aspect >= 1:
            self.half_width = half_view
            self.half_height = half_view / aspect
        else:
            self.half_width = half_view * aspect
            self.half_height = half_view
        self.pixel_size = (self.half_width * 2) / hsize
Esempio n. 5
0
def get_rotation_3d_matrix(vpn_x, vpn_y, vpn_z, vup_x, vup_y, vup_z):
	#Get vpn and vup into vector/matrices
	vpn_point = Point()
	vpn_point.x = vpn_x
	vpn_point.y = vpn_y
	vpn_point.z = vpn_z
	vpn_vec3d = vpn_point.to_vector3d()
	vup_point = Point()
	vup_point.x = vup_x
	vup_point.y = vup_y
	vup_point.z = vup_z
	vup_vec3d  = vup_point.to_vector3d()
	
	#Calc R X,Y,Z vectors
	#|v| = sqrt(v dot v)
	Rz = numpy.divide(vpn_vec3d , matrix.magnitude(vpn_vec3d))
	Rx = numpy.divide( numpy.cross(vup_vec3d,Rz), matrix.magnitude(numpy.cross(vup_vec3d,Rz)) )
	Ry = numpy.cross(Rz,Rx)
	
	#Populate 4D transform matrix
	m = matrix.identity_matrix(4,4)
	r1x = Rx[0]
	r2x = Rx[1]
	r3x = Rx[2]
	r1y = Ry[0]
	r2y = Ry[1]
	r3y = Ry[2]
	r1z = Rz[0]
	r2z = Rz[1]
	r3z = Rz[2]
	m[0,0] = r1x
	m[0,1] = r2x
	m[0,2] = r3x
	m[1,0] = r1y
	m[1,1] = r2y
	m[1,2] = r3y
	m[2,0] = r1z
	m[2,1] = r2z
	m[2,2] = r3z
	return m
Esempio n. 6
0
 def __init__(self):
     self.id = str.format("%032x" % random.getrandbits(128))
     self.parent = None
     self.transform = identity_matrix()
     self.material = material()
Esempio n. 7
0
def get_scale_matrix(scale_x,scale_y,scale_z=1):
	scale_matrix = matrix.identity_matrix(4,4)
	scale_matrix[0,0] = scale_x
	scale_matrix[1,1] = scale_y
	scale_matrix[2,2] = scale_z
	return scale_matrix
Esempio n. 8
0
def get_translation_matrix(trans_x, trans_y, trans_z=0):
	translation_matrix = matrix.identity_matrix(4,4)
	translation_matrix[0,3] = trans_x
	translation_matrix[1,3] = trans_y
	translation_matrix[2,3] = trans_z
	return translation_matrix
def step_impl(context):
    assert context.t == identity_matrix()
Esempio n. 10
0
 def __init__(self):
     self.transform = identity_matrix()
     self.test = True
     super().__init__()
Esempio n. 11
0
def step_impl(context):
    assert context.s.transform == identity_matrix()
Esempio n. 12
0
 def __init__(self):
     self.transform = identity_matrix()