In [5]:
%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload
In [6]:
import numpy as np
from city import *
In [43]:
coordinates = np.array(
              [[7.000, 1.000],
               [4.000, 2.732],
               [3.000, 1.000],
               [5.000, 1.000],
               [3.000, 4.464],
               [1.000, 4.464],
               [6.000, 2.732],
               [1.000, 1.000],
               [7.000, 4.464],
               [2.000, 2.732],
               [5.000, 4.464]])
In [44]:
my_plan = Plan(coordinates)
my_plan.define_triangles()
my_plan.get_all_sides();
In [45]:
my_plan.try_triangles()
# my_plan.plot_triangles(triangle_id=-10);
All triangles seem to be defined correctly!
  Tip: use this method to confirm visually: plot_triangles()
No description has been provided for this image
In [50]:
my_plan.refine_mesh()
my_plan.plot_coordinates();
Refining mesh...initial status:
  refinements:  3
  points:       361
  triangles:    640
  sides:        1000
  side length:  0.25
Refinement complete...final status:
  refinements:  4
  points:       1361
  triangles:    2560
  sides:        3920
  side length:  0.125
Time taken for refinement: 595.112409 seconds
No description has been provided for this image
In [ ]:
my_plan = Plan(coordinates)
my_plan.plot_coordinates();
No description has been provided for this image
In [ ]:
print(my_plan.side_length)
2
In [ ]:
triangles = [[7, 9, 8]]
my_plan = Plan(coordinates)
my_plan.try_triangles([[7, 9, 2],
                       [9, 1, 2]], triangle_id=range(2))
WARNING: You should have 10 triangles --> currently only 2
All triangles seem to be defined correctly!
  Tip: use this method to confirm visually: plot_triangles()
No description has been provided for this image
In [ ]:
my_plan.define_triangles()
In [ ]:
my_plan.plot_triangles()
print(len(my_plan.triangles))
my_plan.triangles
10
Out[ ]:
[[0, 3, 6],
 [1, 2, 3],
 [1, 2, 9],
 [1, 3, 6],
 [1, 4, 9],
 [1, 4, 10],
 [1, 6, 10],
 [2, 7, 9],
 [4, 5, 9],
 [6, 8, 10]]
No description has been provided for this image
In [ ]:
my_plan.define_shared_sides()
print(my_plan.shared_sides)
my_plan.plot_shared_sides([my_plan.shared_sides[2]])
The sides you provided seem to be defined correctly!
[[[3, 6], [0, 3]], [[1, 2], [1, 2]], [[1, 3], [1, 3]], [[1, 9], [2, 4]], [[9, 2], [2, 7]], [[1, 6], [3, 6]], [[1, 4], [4, 5]], [[9, 4], [4, 8]], [[1, 10], [5, 6]], [[10, 6], [6, 9]]]
Out[ ]:
No description has been provided for this image
No description has been provided for this image
In [ ]:
my_plan.get_all_sides()
Out[ ]:
[[0, 3],
 [3, 6],
 [0, 6],
 [1, 2],
 [2, 3],
 [1, 3],
 [2, 9],
 [1, 9],
 [1, 6],
 [1, 4],
 [4, 9],
 [4, 10],
 [1, 10],
 [6, 10],
 [2, 7],
 [7, 9],
 [4, 5],
 [5, 9],
 [6, 8],
 [8, 10]]
In [ ]:
 
20
16
No description has been provided for this image
In [ ]:
len([[2, 3, 5]])
In [ ]:
triangles = [[7, 9, 2],
             [9, 1, 2],
             [1, 3, 6],
             [3, 6, 0],
             [5, 9, 4],
             [9, 4, 1],
             [4, 1, 10],
             [1, 10, 6],
             [10, 6, 8],
             [1, 2, 3]]
my_plan = Plan(coordinates, triangles)
# my_plan.plot_triangle(9)
my_plan.plot_triangle(range(10))
# my_plan.plot_triangle([2, 7])
my_plan.check_triangles()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[16], line 11
      1 triangles = [[7, 9, 2],
      2              [9, 1, 2],
      3              [1, 3, 6],
   (...)
      9              [10, 6, 8],
     10              [1, 2, 3]]
---> 11 my_plan = Plan(coordinates, triangles)
     12 # my_plan.plot_triangle(9)
     13 my_plan.plot_triangle(range(10))

TypeError: Plan.__init__() takes 2 positional arguments but 3 were given
In [ ]:
# my_plan.define_shared_sides([[[9, 2], [0, 1]]])
sides = [[[9, 2], [0, 8]]]
my_plan.define_shared_sides(sides)
my_plan.plot_shared_sides(range(len(sides)));
In [ ]:
my_plan.get_kapsalon_coordinates()
my_plan.get_bar_coordinates()
my_plan.plot_everything();
In [ ]:
 
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 my_plan.get_all_sides()

NameError: name 'my_plan' is not defined

Task 3:

Run the cell below to check your work, but don't change anything. If the cell runs without error, you will pass the assignment once you commit it and push it to GitHub.

In [ ]:
x=1
assert (
    x==1), (
        'cool')
In [ ]:
import numpy as np
import sys
# np.set_printoptions()
np.set_printoptions(precision=3,
                    threshold=sys.maxsize,
                    floatmode='fixed')
x = np.array([[1.312323,2.,3.],[1.,2.,3.]])
print(x)

End of notebook.

© Copyright 2024 MUDE TU Delft. This work is licensed under a CC BY 4.0 License.