Skip to content

antonin-lfv/Utils

Repository files navigation

Tools documentation


Index

  1. Interpolations
    1. 3D linear interpolation
    2. 3D Bezier interpolation
  2. Bezier curves
    1. 2D Bezier curves
    2. 3D Bezier curves
  3. Keras Network Vizualisation
  4. Simple ANN Vizualisation (New !)
  5. Graph plot with Plotly
    1. 2D graph plot
    2. 3D graph plot
  6. Circles intersection
  7. Plot N points with distances between
  8. 3D structure generation wizard (New !)


Interpolations

3D linear interpolation

🔗 code source

After creating your object with your matrix (creates with numpy and lambda functions or just with a $n*m$ numpy matrix), 3 methods are available :

# m is a numpy matrix
MyInterp = Interpolator(matrix=m)
# 1. With color gradient (unique plot)
MyInterp.graph_3D_color(display=True)  # display=True to juste plot this figure

Capture d’écran 2022-03-29 à 21 43 32


# 2. With lines (unique plot)
MyInterp.graph_3D_line(display=True)

Capture d’écran 2022-03-29 à 21 39 50


# 3. Subplot with gradient and lines
MyInterp.subplot_line_gradient()

Capture d’écran 2022-03-29 à 21 38 48

If Display is False, then the function will return the plotly.fig object


3D Bezier interpolation

🔗 code source

With a numpy matrix, you can recreate the surface

from Interpolations.Bezier_interpolation_3D.BezierInterpolation3D import *
import pandas as pd
import numpy as np

# real data
z_data_1 = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv',
                       nrows=10)

model = BezierInterpolation(matrix=np.array(z_data_1))
model.show_bezier()

Capture d’écran 2022-06-10 à 22 46 31


Bezier curves

2D Bezier curves

🔗 code source

With the list of lists of all points

from plotly.offline import plot
from BezierCurves.Bezier_curves_2D.BezierCurves2D import *

Points_control = [[2, 1], [4, 7], [5, 7], [8, 4], [10, 8], [13, 15]]
model = Bezier_2d(points_control=Points_control)
x_b, y_b, fig_b = model.show_bezier()
plot(fig_b)

Capture d’écran 2022-06-10 à 22 50 20


3D Bezier curves

🔗 code source

With the list of lists of all points

from BezierCurves.Bezier_curves_3D.BezierCurves3D import *
from plotly.offline import plot
from numpy import array as a

points_control = a([[0, 0, 0], [1, 4, 2], [2, 2, 4], [2, 1, 0]])
model = Bezier_3d(points_control=points_control, show_control_points=True)
x_curve, y_curve, z_curve, x_pts, y_pts, z_pts, fig_b = model.show_bezier()
plot(fig_b)

Capture d’écran 2022-06-10 à 22 52 14


Keras Network Vizualisation

🔗 code source

After creating your object with your model, use the method called plot to vizualise your network

# Model
model = Sequential()
model.add(Dense(8, activation='relu'))
model.add(Dense(7, activation='relu'))
model.add(Dense(13, activation='softmax'))
model.add(Dense(10, activation='sigmoid'))
model.add(Dense(4, activation='softmax'))
model.add(Dense(4, activation='relu'))
model.add(Dense(1))

MyFirstNN = VizNN(model)
MyFirstNN.plot_NN()

Capture d’écran 2022-03-30 à 11 02 32


Simple ANN Vizualisation

🔗 code source

Plot a neural network with the number of neurons per layer

from SimpleANNVizualisation.ANNVizualisation import *

NN = NeuralNetworkPlot(layers_list=[10, 10, 5, 5, 1])
NN.plot_neural_network()

ann


Graph plot with Plotly

2D graph plot

🔗 code source

To plot your graph, just fill the csv file (aretes_2D, noeuds_2D) with your data, then :

from PlotGraph.D2Graph.D2GraphPlot import *

# Data
node_csv_2d = pd.read_csv('data/noeuds_2D.csv', sep=';')
edge_csv_2d = pd.read_csv('data/aretes_2D.csv', sep=';')
# Plot
fig_2D = graphe_2d(nodes=node_csv_2d, edges=edge_csv_2d, titre="myTitle")
plot(fig_2D)

Capture d’écran 2022-04-29 à 10 33 51



3D graph plot

🔗 code source

To plot your graph, just fill the csv file (aretes_3D, noeuds_3D) with your data, then :

from PlotGraph.D3Graph.D3GraphPlot import *

# Data
node_csv_3D = pd.read_csv('data/neouds_3D.csv', sep=';')
edge_csv_3D = pd.read_csv('data/aretes_3D.csv', sep=';')
# Plot
fig_3D = graphe_3d(nodes=node_csv_3D, edges=edge_csv_3D)
plot(fig_3D)

Capture d’écran 2022-06-08 à 21 13 20


Circles intersection

🔗 code source

You just need to put the centers coordinates and the radius of each circles. One list for the x, another one for the y, and a last for the radius. You will obtain the solution of the system of equations allowing to find the intersection of n circles. If the intersection does not exist geometrically, the solution corresponds to the closest point of all circles.

from CirclesIntersection.CirclesIntersect import *
import warnings
warnings.filterwarnings('ignore', 'The iteration is not making good progress')

centres_x = [0, 3, -0.49]
centres_y = [0, 0, 1.93]
rayons = [4.89, 2.89, 4.65]

print(solve_inter_circles(centres_x=centres_x, centres_y=centres_y, rayons=rayons))
OUT : (4.099264653603768, 2.669805721160483)

Plot N points with distances between

🔗 code source

If you only know the distance between n points, this code will plot them. (Not the only way to plot them)

from PlotNpoints.Npoints import *

# symmetrical matrix 
# The value of coord i,j gives the distance between the ith and the jth points (ordered by index)
Points = [
    [0, 3, 2, 4.894],
    [3, 0, 4, 2.899113],
    [2, 4, 0, 4.65457],
    [4.894, 2.899113, 4.65457, 0]
]

plotPoints(Points)

Results

Capture d’écran 2022-08-30 à 14 29 19


Proof

Capture d’écran 2022-06-08 à 21 13 20


3D structure generation wizard

🔗 code source

Open the wizard from here and start creating your 3D structure. You can also import your data, and visualize the generated structure.


Capture d’écran 2022-10-01 à 22 09 52