eeg_positions.find_point_at_fraction¶
- eeg_positions.find_point_at_fraction(p1, p2, p3, frac)[source]¶
Find a point on an arc spanned by three points.
Given three points p1, p2 and p3 on a sphere with origin (0, 0, 0), find the coordinates of a point at a fraction frac of the overall distance on an arc spanning from p1 over p2 to p3. Given this assumption, for fractions of zero, point will equal p1; for fractions of one, point will equal p3; and for fractions of one half, point will equal p2 [1].
- Parameters:
- Returns:
- point
tuple
The x, y, z cartesian coordinates of the point at fraction.
- point
Notes
The assumptions of this function require p1, p2 and p3 to be equidistant from the origin. They must not be collinear (i.e., all be along one line) and none of the points may be equal.
References
[1]Nominal Animal (https://math.stackexchange.com/users/318422/nominal-animal), find intermediate points on small circle of a sphere, URL (version: 2018-06-02): https://math.stackexchange.com/q/2805204
Examples
>>> p1 = (1., 0., 0.) >>> p2 = (0., 0., 1.) >>> p3 = (-1., 0., 0.) >>> find_point_at_fraction(p1, p2, p3, frac=0.) (1.0, 0.0, 0.0) >>> find_point_at_fraction(p1, p2, p3, frac=.5) (0.0, 0.0, 1.0) >>> find_point_at_fraction(p1, p2, p3, frac=1.) (-1.0, 0.0, 0.0) >>> find_point_at_fraction(p1, p2, p3, frac=.3) (0.5878, 0.0, 0.809)