Ask Your Question
1

polyhedron pb

asked 2023-08-20 13:55:11 +0100

ortollj gravatar image

updated 2023-08-20 16:42:59 +0100

Hi

It seems that the polyhedron function does not appreciate having a point too close to [0,0,0]

edited:16h36 20/08/2023 remove variable shiftv in textToPlt which was not set in my code snippet below,sorry.

def addAxis(plt,textToPlt,xBound,yBound,zBound) :
    # add axis for real part
    plt += arrow3d((0, 0, 0), (xBound, 0, 0), color='blue',width=1,radius=0.01)
    plt += text3d("X", (xBound, 0, 0), fontsize='200%', color='blue')
    plt += arrow3d((0, 0, 0), (0, yBound, 0), color='green',width=1,radius=0.01)
    plt += text3d("Y", (0, yBound, 0), fontsize='200%', color='green')
    plt += arrow3d((0, 0, 0), (0, 0, zBound), color='red',width=1,radius=0.01)
    plt += text3d("Z", (0,0, zBound), fontsize='200%', color='red')
    plt+=textToPlt
    return plt


xBound=1 ;yBound=1 ;zBound=1

textToPlt = text3d("triangle",vector( (xBound, yBound, zBound)), fontsize='300%', fontweight=800)


# this one is ok
PL=[[-0.01850472408517678, -0.0001969154774790170-0.1, 0], 
    [0.528252049962465, 0.518079657915348, 1], 
    [0.700606532965328, -0.1802168993960041, 0]]
# but this one is KO
PL=[[-0.01850472408517678, -0.0001969154774790170, 0], 
    [0.528252049962465, 0.518079657915348, 1], 
    [0.700606532965328, -0.1802168993960041, 0]]


plt=Graphics()
plt+= point3d(PL, color='black',size=20)
plt=addAxis(plt,textToPlt,xBound,yBound,zBound)
show(plt)
P=Polyhedron(PL)
Pc=P.centroid()
edit retag flag offensive close merge delete

Comments

I forgot to precise: Sagemath 10.0 ,Ubuntu 22.04.2 LTS ,WSL2 ,W11

Apparently it's a known issue ? :sage support google

stanford polyhedra tutorial

ortollj gravatar imageortollj ( 2023-08-20 16:29:24 +0100 )edit

The tutorial you mention is not the "stanford polyhedra tutorial" but the Sage polyhedra tutorial.

It turns out a copy (dating back to Sage 9.3.beta9) is hosted at Stanford.

But the more natural link would be:

slelievre gravatar imageslelievre ( 2023-08-21 22:34:32 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-08-20 18:31:00 +0100

ortollj gravatar image

updated 2023-08-21 08:01:30 +0100

a little weird workarround !

PrL=[]
for pt in PL:
    ptr=[]
    for v in pt :
        ptr.append(RDF((v.n(20)*10^8)/10^8))
        #ptr.append(RDF(v.n(20)))
    PrL.append(ptr)

plt=Graphics()
plt+= point3d(PL, color='black',size=20)
plt=addAxis(plt,textToPlt,xBound,yBound,zBound)
P=Polyhedron(PrL)
Pc=P.centroid()
plt+= point3d(Pc, color='red',size=20) 
show(plt)

edited :21/08/23 : much more simple the solution is given in the post sage google support (link in the comment above) :

P=Polyhedron(PL,backend='ppl', base_ring=QQ)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-08-20 13:55:11 +0100

Seen: 150 times

Last updated: Aug 21 '23