コード例 #1
0
def reflectAboutPoint(ref_point, dim=3):
    """
    Return a matrix which flip across specific point on homogeneouse coordinates.
    """
    A = reflection('origin', dim, mode='homogeneous')
    T = translation(ref_point, dim)
    T = gutil.dot(T, T)
    return gutil.dot(T, A)
コード例 #2
0
def reflectAboutLine(u, v, dim=3, mode='homogeneous'):
    """
    Return a matrix which flip across the line which across point u and v
    on xy coordinates.
    """
    dir_vec = np.asarray(u) - np.asarray(v)
    x_axis = [0 for d in range(dim)]
    x_axis[0] = 1
    angle = includedAngle(dir_vec, x_axis, mode)
    R = rotation(angle, mode)
    T = reflection('x', dim)
    # First, reflect across the x-axis and then rotate twice about included angle.
    # A = R*R*T
    A = gutil.dot(R, T)
    A = gutil.dot(R, A)
    return A
コード例 #3
0
ファイル: reflection.py プロジェクト: guhwanbae/GuLA
#               specific point or line. Scaling is linear transform.

import numpy as np
import gula.geometry as ggeo
import gula.vec as gvec
import gula.mat as gmat
import gula.util as gutil

# Reflect across a reference axis.
x = ggeo.homogeneousVector([2, 2, 1], dim=3)
print('Point on homogeneous, x =\n', x)

A = ggeo.reflection('y', dim=3, mode='homogeneous')
print('The matrix, A, which reflect across by y-axis, A =\n', A)

b = gutil.dot(A, x)
print('Reflected point, A*x = b =\n', b)

# Reflect across a origin point.
x = ggeo.homogeneousVector([2, 2, 1], dim=3)
print('Point on homogeneous, x =\n', x)

A = ggeo.reflection(ref_axis='origin', dim=3, mode='homogeneous')
print('The matrix, A, which reflect across origin point, A =\n', A)

b = gutil.dot(A, x)
print('Reflected point, A*x = b =\n', b)

# Reflect across a specific point.
x = ggeo.homogeneousVector([2, 2, 1], dim=3)
print('Point on homogeneous, x =\n', x)
コード例 #4
0
ファイル: matrix_as_function.py プロジェクト: guhwanbae/GuLA
import gula.util as gutil
"""
R is row label of matrix.
C is column label of matrix.
"""
R = {'a', 'b'}
C = {'#', '@', '?'}

A = gmat.matrix((R, C),
                {d: i + 1
                 for i, d in enumerate(gutil.cartesianProduct(R, C))})
print('Matrix A=')
print(A)

x = gvec.vector(C, {c: 1 for c in C})
print('Vector x=')
print(x)
"""
Set(Label) C is a domain of function.
Set R is a co-domain of function.
So, RxC matrix is model of (C->R) function.
"""

print('Dot product, A*x=b')
print('Vector b=')
print(gutil.dot(A, x))
"""
(x->M*x) is function of (C->R).
The domain of vector b is range of above function.
"""
コード例 #5
0
# Author    :   Gu-hwan Bae
# Summary   :   Denotation of euclidian and homogeneous coordinates.

import gula.geometry as ggeo
import gula.vec as gvec
import gula.util as gutil

x_eu = gvec.getVector(['x', 'y'], [12, 30])
A_eu = ggeo.scale([1, 2], dim = 2, mode = 'euclidian')

print('Point on 2D Euclidian, x =\n', x_eu)
print('Scaling matrix, A =\n', A_eu)

b_eu = gutil.dot(A_eu, x_eu)
print('Scaled point on 2D Euclidian, A*x = b =\n', b_eu)

x_hm = ggeo.homogeneousVector([1, 1, 1], dim = 3)
A_hm = ggeo.scale([1, 2, 1], dim = 3, mode = 'homogeneous')
print('Point on Homogeneous, x =\n', x_hm)
print('Scaling matrix, A =\n', A_hm)

b_hm = gutil.dot(A_hm, x_hm)
print('Scaled point on Homogeneous, A*x = b =\n', b_hm)

コード例 #6
0
# Author    :   Gu-hwan Bae
# Summary   :   Modeling a translation. Translation is linear transform on
#               the homogeneouse filed.

import gula.geometry as ggeo
import gula.mat as gmat
import gula.util as gutil

x_hm = ggeo.homogeneousVector([0, 0, 1], dim=3)
print('Point on 3D Homogeneous coordinates, x =\n', x_hm)

A_hm = ggeo.translation([2, 2, 1], dim=3)
print('Translation matrix, A =\n', A_hm)

b_hm = gutil.dot(A_hm, x_hm)
print('Translated point on 3D Homogeneous coordinates, A*x = b =\n', b_hm)

A = ggeo.translation([1, 1, 1], dim=3)
print('Translation matrix, A =\n', A)

B = gmat.listlist2matrix(['x', 'y', 'u'], ['0', '1', '2', '3'],
                         [[0, 1, 2, 5], [0, 1, 2, 0], [1, 1, 1, 1]])
print('The matrix that columns are point vectors, B =\n', B)

X = gutil.dot(A, B)
print('Translated points, A*B = X = \n', X)