Add more shuffles and rename combines for clarity
This commit is contained in:
parent
0b0c913332
commit
2487d71879
|
@ -21,7 +21,7 @@ pub struct LineSegmentF32(pub F32x4);
|
|||
impl LineSegmentF32 {
|
||||
#[inline]
|
||||
pub fn new(from: &Point2DF32, to: &Point2DF32) -> LineSegmentF32 {
|
||||
LineSegmentF32(from.0.combine_axaybxby(to.0))
|
||||
LineSegmentF32(from.0.concat_xy_xy(to.0))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -36,12 +36,12 @@ impl LineSegmentF32 {
|
|||
|
||||
#[inline]
|
||||
pub fn set_from(&mut self, point: &Point2DF32) {
|
||||
self.0 = point.0.combine_axaybzbw(self.0)
|
||||
self.0 = point.0.concat_xy_zw(self.0)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_to(&mut self, point: &Point2DF32) {
|
||||
self.0 = self.0.combine_axaybxby(point.0)
|
||||
self.0 = self.0.concat_xy_xy(point.0)
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
|
@ -97,8 +97,8 @@ impl LineSegmentF32 {
|
|||
let (from_from, to_to) = (self.0.xyxy(), self.0.zwzw());
|
||||
let d_d = to_to - from_from;
|
||||
let mid_mid = from_from + d_d * F32x4::splat(t);
|
||||
(LineSegmentF32(from_from.combine_axaybxby(mid_mid)),
|
||||
LineSegmentF32(mid_mid.combine_axaybxby(to_to)))
|
||||
(LineSegmentF32(from_from.concat_xy_xy(mid_mid)),
|
||||
LineSegmentF32(mid_mid.concat_xy_xy(to_to)))
|
||||
}
|
||||
|
||||
// Returns the left segment first, followed by the right segment.
|
||||
|
@ -225,9 +225,9 @@ impl LineSegmentF32 {
|
|||
|
||||
// http://www.cs.swan.ac.uk/~cssimon/line_intersection.html
|
||||
pub fn intersection_t(&self, other: &LineSegmentF32) -> f32 {
|
||||
let d0d1 = self.vector().0.combine_axaybxby(other.vector().0);
|
||||
let d0d1 = self.vector().0.concat_xy_xy(other.vector().0);
|
||||
let offset = other.from() - self.from();
|
||||
let factors = d0d1.combine_awazbybx(offset.0);
|
||||
let factors = d0d1.concat_wz_yx(offset.0);
|
||||
let terms = d0d1 * factors;
|
||||
let t = (terms[3] - terms[2]) / (terms[0] - terms[1]);
|
||||
//println!("intersection_t({:?}, {:?})={} (d0d1={:?}, factors={:?})", self, other, t, d0d1, factors);
|
||||
|
|
|
@ -216,12 +216,12 @@ impl<'s> CubicSegment<'s> {
|
|||
let tttt = F32x4::splat(t);
|
||||
|
||||
let (p0p3, p1p2) = (self.0.baseline.0, self.0.ctrl.0);
|
||||
let p0p1 = p0p3.combine_axaybxby(p1p2);
|
||||
let p0p1 = p0p3.concat_xy_xy(p1p2);
|
||||
|
||||
// p01 = lerp(p0, p1, t), p12 = lerp(p1, p2, t), p23 = lerp(p2, p3, t)
|
||||
let p01p12 = p0p1 + tttt * (p1p2 - p0p1);
|
||||
let pxxp23 = p1p2 + tttt * (p0p3 - p1p2);
|
||||
let p12p23 = p01p12.combine_azawbzbw(pxxp23);
|
||||
let p12p23 = p01p12.concat_zw_zw(pxxp23);
|
||||
|
||||
// p012 = lerp(p01, p12, t), p123 = lerp(p12, p23, t)
|
||||
let p012p123 = p01p12 + tttt * (p12p23 - p01p12);
|
||||
|
@ -230,10 +230,10 @@ impl<'s> CubicSegment<'s> {
|
|||
// p0123 = lerp(p012, p123, t)
|
||||
let p0123 = p012p123 + tttt * (p123 - p012p123);
|
||||
|
||||
baseline0 = LineSegmentF32(p0p3.combine_axaybxby(p0123));
|
||||
ctrl0 = LineSegmentF32(p01p12.combine_axaybxby(p012p123));
|
||||
baseline1 = LineSegmentF32(p0123.combine_axaybzbw(p0p3));
|
||||
ctrl1 = LineSegmentF32(p012p123.combine_azawbzbw(p12p23));
|
||||
baseline0 = LineSegmentF32(p0p3.concat_xy_xy(p0123));
|
||||
ctrl0 = LineSegmentF32(p01p12.concat_xy_xy(p012p123));
|
||||
baseline1 = LineSegmentF32(p0123.concat_xy_zw(p0p3));
|
||||
ctrl1 = LineSegmentF32(p012p123.concat_zw_zw(p12p23));
|
||||
}
|
||||
|
||||
(Segment {
|
||||
|
|
|
@ -131,10 +131,10 @@ impl Transform3DF32 {
|
|||
pub fn from_submatrices(a: Matrix2x2F32, b: Matrix2x2F32, c: Matrix2x2F32, d: Matrix2x2F32)
|
||||
-> Transform3DF32 {
|
||||
Transform3DF32 {
|
||||
c0: a.0.combine_axaybxby(c.0),
|
||||
c1: a.0.combine_azawbzbw(c.0),
|
||||
c2: b.0.combine_axaybxby(d.0),
|
||||
c3: b.0.combine_azawbzbw(d.0),
|
||||
c0: a.0.concat_xy_xy(c.0),
|
||||
c1: a.0.concat_zw_zw(c.0),
|
||||
c2: b.0.concat_xy_xy(d.0),
|
||||
c3: b.0.concat_zw_zw(d.0),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,22 +187,22 @@ impl Transform3DF32 {
|
|||
|
||||
#[inline]
|
||||
pub fn upper_left(&self) -> Matrix2x2F32 {
|
||||
Matrix2x2F32(self.c0.combine_axaybxby(self.c1))
|
||||
Matrix2x2F32(self.c0.concat_xy_xy(self.c1))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upper_right(&self) -> Matrix2x2F32 {
|
||||
Matrix2x2F32(self.c2.combine_axaybxby(self.c3))
|
||||
Matrix2x2F32(self.c2.concat_xy_xy(self.c3))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn lower_left(&self) -> Matrix2x2F32 {
|
||||
Matrix2x2F32(self.c0.combine_azawbzbw(self.c1))
|
||||
Matrix2x2F32(self.c0.concat_zw_zw(self.c1))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn lower_right(&self) -> Matrix2x2F32 {
|
||||
Matrix2x2F32(self.c2.combine_azawbzbw(self.c3))
|
||||
Matrix2x2F32(self.c2.concat_zw_zw(self.c3))
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Invertible_matrix#Blockwise_inversion
|
||||
|
|
1283
simd/src/x86.rs
1283
simd/src/x86.rs
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue