further refactoring
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import division
|
||||
from numpy import sin, cos, dot, array, ndarray, vstack, transpose, sqrt
|
||||
from numpy.linalg import solve, norm
|
||||
|
||||
@@ -26,7 +25,8 @@ def reflection(angle):
|
||||
[-sin(2 * angle), -cos(2 * angle)]])
|
||||
|
||||
def func(x):
|
||||
# why not use mat @ x???
|
||||
# we do not use matrix-multiplication here because this is meant to work
|
||||
# on an array of points
|
||||
return dot(x, mat)
|
||||
|
||||
return func
|
||||
@@ -50,7 +50,8 @@ def reflection3D(angle):
|
||||
|
||||
def rotation(angle, midpoint=None):
|
||||
midpoint = midpoint or [0.0, 0.0]
|
||||
mat = array([[cos(angle), -sin(angle)], [sin(angle), cos(angle)]])
|
||||
mat = array([[cos(angle), -sin(angle)],
|
||||
[sin(angle), cos(angle)]])
|
||||
midpoint = array(midpoint)
|
||||
vec = midpoint - dot(midpoint, mat)
|
||||
trans = translation(vec)
|
||||
@@ -63,7 +64,9 @@ def rotation(angle, midpoint=None):
|
||||
|
||||
def rotation3D(angle):
|
||||
mat = array(
|
||||
[[cos(angle), -sin(angle), 0.0], [sin(angle), cos(angle), 0.0], [0.0, 0.0, 1.0]]
|
||||
[[cos(angle), -sin(angle), 0.0],
|
||||
[sin(angle), cos(angle), 0.0],
|
||||
[0.0, 0.0, 1.0]]
|
||||
)
|
||||
|
||||
def func(xx):
|
||||
@@ -74,7 +77,8 @@ def rotation3D(angle):
|
||||
|
||||
def translation(vec):
|
||||
def trans(x):
|
||||
return [x[0] + vec[0], x[1] + vec[1]]
|
||||
return [x[0] + vec[0],
|
||||
x[1] + vec[1]]
|
||||
|
||||
def func(x):
|
||||
return array(list(map(trans, x)))
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import division
|
||||
from numpy import (
|
||||
cos,
|
||||
sin,
|
||||
@@ -28,7 +26,6 @@ from numpy import (
|
||||
array,
|
||||
linspace,
|
||||
transpose,
|
||||
vstack,
|
||||
sqrt,
|
||||
)
|
||||
from ._functions import rotation3D, reflection3D, intersection_line_circle
|
||||
|
||||
@@ -44,8 +44,9 @@ def compute_shifted_gears(m, alpha, t1, t2, x1, x2):
|
||||
|
||||
def d_root_inv(x):
|
||||
return 1.0 / np.cos(x) - 1
|
||||
|
||||
alpha_w = find_root(alpha, root_inv, d_root_inv)
|
||||
|
||||
# use scipy (sp.optimize.minimize(f, f0, df).x) here (as we depent on scipy anyways)
|
||||
alpha_w = find_root(alpha, root_inv, d_root_inv)
|
||||
dist = m * (t1 + t2) / 2 * np.cos(alpha) / np.cos(alpha_w)
|
||||
return dist, alpha_w
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import division
|
||||
from numpy import cos, sin, arccos, pi, array, linspace, transpose, vstack
|
||||
from ._functions import rotation, reflection
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import division
|
||||
from numpy import (
|
||||
tan,
|
||||
cos,
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * This program is free software: you can redistribute it and/or modify *
|
||||
# * it under the terms of the GNU General Public License as published by *
|
||||
# * the Free Software Foundation, either version 3 of the License, or *
|
||||
# * (at your option) any later version. *
|
||||
# * *
|
||||
# * This program is distributed in the hope that it will be useful, *
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
# * GNU General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU General Public License *
|
||||
# * along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
|
||||
import numpy as np
|
||||
from .involute_tooth import InvoluteTooth, InvoluteRack
|
||||
from .bevel_tooth import BevelTooth
|
||||
|
||||
Reference in New Issue
Block a user