I am trying to convert some Mathematica code into python and I didn't know how to handle the following function. Is there a way to go about is using sympy or other python module? TPUV, AM1UV and GUV are vectors computed by other accompanying functions.
perpUnitVector[]:=Module[
{sol,a3,b3,c3,a4,b4,c4},
sol=Quiet[Solve[
{a3,b3,c3}.TPUV==0&&
{a3,b3,c3}.AM1UV==0&&
{a3,b3,c3}.{a3,b3,c3}==1&&
Sign[Cross[-GUV,{a3,b3,c3}].Cross[{1,0,0},-GUV]]>0,
{a3,b3,c3},Reals]];
{a4,b4,c4}=Flatten[{a3,b3,c3}/.sol[[1]],1]
]
Test case:
With TPU = {1,3,4}, AM1UV = {4, 5, 6}, GUV = {1,1,1}, Mathematica gives
a4 = -0.408248, b4 = 0.816497, and c4 = -0.408248.
my sympy attempt is here but doesn't seem to work
import numpy as np
import sympy as sym
GUV = [1.0, 1.0, 1.0];
AM1UV = [4.0, 5.0, 6.0];
TPUV = [1.0, 2.0, 3.0];
a3,b3,c3,a4,b4,c4 = sym.symbols('a3 b3 c3 a4 b4 c4')
sol = sym.solveset(np.dot([a3,b3,c3],TPUV),
np.dot([a3,b3,c3],AM1UV),
np.dot([a3,b3,c3],[a3,b3,c3])-1,
np.sign(np.dot(np.cross(-GUV,[a3,b3,c3]),
np.cross([1,0,0],-GUV)))>0,
[a3,b3,c3],S.Reals)
question from:
https://stackoverflow.com/questions/65857160/how-can-i-convert-the-following-mathematica-code-into-sympy