Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UniformTriRefiner gives uncorrect results for transposed arrays #4180

Closed
@miaocb

Description

@miaocb

The following code repeats the problem. Array ele1 is same as ele2 except that it is transpose of ele0, but the refined triangles using ele1 is incorrect.

!/bin/env python

import numpy as np
import matplotlib.tri as tri
import matplotlib.pyplot as plt

x = np.array([ 120.39299774, 120.59100342, 120.42900085, 120.31700134])
y = np.array([ 33.99900055, 34.00899887, 34.18799973, 34.18399811])

ele0 = np.array([[2, 2], [0, 1], [3, 0]])
ele1 = ele0.transpose() # ele1 is same as ele2 except that it is transpose of ele0
ele2 = np.array([[2, 0, 3], [2, 1, 0]])

triang1 = tri.Triangulation(x, y, ele1)
triang2 = tri.Triangulation(x, y, ele2)

refiner1 = tri.UniformTriRefiner(triang1)
refiner2 = tri.UniformTriRefiner(triang2)

fine_triang1 = refiner1.refine_triangulation(subdiv=1)
fine_triang2 = refiner2.refine_triangulation(subdiv=1)

fig = plt.figure()
ha1 = fig.add_subplot(121)
ha1.set_aspect('equal')
plt.triplot(fine_triang1, color='b', linewidth=0.5)
plt.triplot(triang1, color='k', linewidth=1)
plt.title('refine_triang1 is incorrect')

ha2 = fig.add_subplot(122)
ha2.set_aspect('equal')
plt.triplot(fine_triang2, color='b', linewidth=0.5)
plt.triplot(triang2, color='k', linewidth=1)
plt.title('refine_triang2 is correct')

plt.show()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions