def depth_image_to_skeleton(fDepthX, fDepthY, usDepthValue): """returns Vector4""" ## ## Depth is in meters in skeleton space. ## The depth image pixel format has depth in millimeters shifted left by 3. ## fSkeletonZ = (usDepthValue >> 3) / 1000.0 ## ## Center of depth sensor is at (0,0,0) in skeleton space, and ## and (160,120) in depth image coordinates. Note that positive Y ## is up in skeleton space and down in image coordinates. ## fSkeletonX = (fDepthX - 0.5) * (_NUI_CAMERA_DEPTH_IMAGE_TO_SKELETON_MULTIPLIER_320x240 * fSkeletonZ) * 320.0 fSkeletonY = (0.5 - fDepthY) * (_NUI_CAMERA_DEPTH_IMAGE_TO_SKELETON_MULTIPLIER_320x240 * fSkeletonZ) * 240.0 ## ## Return the result as a vector. ## v4 = Vector() v4.x = fSkeletonX v4.y = fSkeletonY v4.z = fSkeletonZ v4.w = 1.0 return v4
def create_vector_midpoint(one, two): mid = Vector() mid.x = (one.x + two.x)/2 mid.y = (one.y + two.y)/2 mid.z = one.z mid.w = one.w return mid