Vector3d#

class orix.vector.Vector3d(data=None)[source]#

Bases: Object3d

Three-dimensional vectors.

Vectors \(\mathbf{v} = (x, y, z)\) support the following mathematical operations:

  • Unary negation.

  • Addition to other vectors, numbers, and compatible array-like objects.

  • Subtraction to and from the above.

  • Multiplication to numbers and compatible array-like objects.

  • Division by the same as multiplication. Division by a vector is not defined in general.

Examples

>>> from orix.vector import Vector3d
>>> v = Vector3d([1, 2, 3])
>>> w = Vector3d([[1, 0, 0], [0, 1, 1]])
>>> w.x
array([1, 0])
>>> v.unit
Vector3d (1,)
[[0.2673 0.5345 0.8018]]
>>> -v
Vector3d (1,)
[[-1 -2 -3]]
>>> v + w
Vector3d (2,)
[[2 2 3]
 [1 3 4]]
>>> w - (2, -3)
Vector3d (2,)
[[-1 -2 -2]
 [ 3  4  4]]
>>> 3 * v
Vector3d (1,)
[[3 6 9]]
>>> v / 2
Vector3d (1,)
[[0.5 1.  1.5]]
>>> v / (2, -2)
Vector3d (2,)
[[ 0.5  1.   1.5]
 [-0.5 -1.  -1.5]]

Vectors can be rotated by quaternion-like objects (which are interpreted as basis transformations)

>>> from orix.quaternion import Rotation
>>> R = Rotation.from_axes_angles([0, 0, 1], -45, degrees=True)
>>> v2 = Vector3d([1, 1, 1.])
>>> v3 = R * v2
>>> v3
Vector3d (1,)
[[ 1.4142 -0.      1.    ]]
>>> v3_np = np.dot(R.to_matrix().squeeze(), v2.data.squeeze())
>>> np.allclose(v3.data, v3_np)
True

Attributes

Vector3d.azimuth

Azimuth spherical coordinate, i.e. the angle \(\phi \in [0, 2\pi]\) from the positive z-axis to a point on the sphere, according to the ISO 31-11 standard [Weisstein, 2005].

Vector3d.data

Return the data.

Vector3d.ndim

Return the number of navigation dimensions of the object.

Vector3d.norm

Return the norm of the data.

Vector3d.perpendicular

Return the perpendicular vectors.

Vector3d.polar

Polar spherical coordinate, i.e. the angle \(\theta \in [0, \pi]\) from the positive z-axis to a point on the sphere, according to the ISO 31-11 standard [Weisstein, 2005].

Vector3d.radial

Return the radial spherical coordinate, i.e. the distance from a point on the sphere to the origin, according to the ISO 31-11 standard [Weisstein, 2005].

Vector3d.shape

Return the shape of the object.

Vector3d.size

Return the total number of entries in this object.

Vector3d.unit

Return the unit object.

Vector3d.x

Return or set the x coordinates.

Vector3d.xyz

Return the coordinates as three arrays, useful for plotting.

Vector3d.y

Return or set the y coordinates.

Vector3d.z

Return or set the z coordinate.

Methods

Vector3d.angle_with(other[, degrees])

Return the angles between these vectors in other vectors.

Vector3d.cross(other)

Return the cross product of a vector with another vector.

Vector3d.dot(other)

Return the dot products of the vectors and the other vectors.

Vector3d.dot_outer(other[, lazy, ...])

Return the outer dot products of all vectors and all the other vectors.

Vector3d.draw_circle([projection, figure, ...])

Draw great or small circles with a given opening_angle to to the vectors in the stereographic projection.

Vector3d.empty()

Return an empty object with the appropriate dimensions.

Vector3d.flatten()

Return a new object with the same data in a single column.

Vector3d.from_path_ends(vectors[, close, steps])

Return vectors along the shortest path on the sphere between two or more consectutive vectors.

Vector3d.from_polar(azimuth, polar[, ...])

Initialize from spherical coordinates according to the ISO 31-11 standard [Weisstein, 2005].

Vector3d.get_circle([opening_angle, steps])

Get vectors delineating great or small circle(s) with a given opening_angle about each vector.

Vector3d.get_nearest(x[, inclusive, tiebreak])

Return the vector in x with the smallest angle to this vector.

Vector3d.get_random_sample([size, replace, ...])

Return a new flattened object from a random sample of a given size.

Vector3d.in_fundamental_sector(symmetry)

Project vectors to a symmetry's fundamental sector (inverse pole figure).

Vector3d.inverse_pole_density_function([...])

Plot the Inverse Pole Density Function (IPDF) within the fundamental sector of a given point group symmetry in the stereographic projection.

Vector3d.mean()

Return the mean vector.

Vector3d.pole_density_function([resolution, ...])

Plot the Pole Density Function (PDF) on a given hemisphere in the stereographic projection.

Vector3d.random([shape])

Create object with random data.

Vector3d.reshape(*shape)

Return a new object with the same data in a new shape.

Vector3d.rotate([axis, angle])

Convenience function for rotating this vector.

Vector3d.scatter([projection, figure, ...])

Plot vectors in the stereographic projection.

Vector3d.squeeze()

Return a new object with the same data with length 1-dimensions removed.

Vector3d.stack(sequence)

Return a stacked object from the sequence.

Vector3d.to_polar([degrees])

Return the azimuth \(\phi\), polar \(\theta\), and radial \(r\) spherical coordinates defined as in the ISO 31-11 standard [Weisstein, 2005].

Vector3d.transpose(*axes)

Return a new object with the same data transposed.

Vector3d.unique([return_index, return_inverse])

Return a new object containing only this object's unique entries.

Vector3d.xvector()

Return a unit vector in the x-direction.

Vector3d.yvector()

Return a unit vector in the y-direction.

Vector3d.zero([shape])

Return zero vectors in the specified shape.

Vector3d.zvector()

Return a unit vector in the z-direction.

Examples using Vector3d#

Inverse pole density function

Inverse pole density function

Misorientation from aligning directions

Misorientation from aligning directions

Orientation from aligning directions

Orientation from aligning directions

Subplots

Subplots

Rotating z-vector to high-symmetry crystal directions

Rotating z-vector to high-symmetry crystal directions

Rotations mapping the fundamental sector on S2

Rotations mapping the fundamental sector on S2

Combining rotations

Combining rotations

Wulff net

Wulff net

Plot symmetry operations

Plot symmetry operations

Restrict to fundamental sector

Restrict to fundamental sector

Zoom region inset

Zoom region inset