vector up = set(0, 1, 0); // Start with an arbitrary up vectorvector N = normalize(v@N); // Ensure the normal is normalized// Step 1: Calculate a perpendicular tangent vectorvector tangent = normalize(cross(up, N));// Step 2: Recalculate the up vector to make it orthogonalup = normalize(cross(N, tangent));// Step 3: Create a 3x3 matrix from normal, tangent, and up vectorsmatrix3 mat = set(tangent, up, N);// Step 4: Convert the matrix to a quaternionp@orient = quaternion(mat);