MCPcopy Create free account
hub / github.com/andrewwillmott/splines-lib / Offset

Method Offset

Splines.cpp:2114–2137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2112}
2113
2114Spline2 SL::Offset(const Spline2& spline, float offset)
2115{
2116 float sx0 = spline.xb.y - spline.xb.x;
2117 float sy0 = spline.yb.y - spline.yb.x;
2118 float sd0 = InvSqrtFast(sx0 * sx0 + sy0 * sy0) * offset;
2119
2120 float sx1 = spline.xb.z - spline.xb.x;
2121 float sy1 = spline.yb.z - spline.yb.x;
2122 float sd1 = InvSqrtFast(sx1 * sx1 + sy1 * sy1) * offset;
2123
2124 float sx2 = spline.xb.w - spline.xb.y;
2125 float sy2 = spline.yb.w - spline.yb.y;
2126 float sd2 = InvSqrtFast(sx2 * sx2 + sy2 * sy2) * offset;
2127
2128 float sx3 = spline.xb.w - spline.xb.z;
2129 float sy3 = spline.yb.w - spline.yb.z;
2130 float sd3 = InvSqrtFast(sx3 * sx3 + sy3 * sy3) * offset;
2131
2132 return
2133 {
2134 spline.xb + Vec4f(sy0 * sd0, sy1 * sd1, sy2 * sd2, sy3 * sd3),
2135 spline.yb - Vec4f(sx0 * sd0, sx1 * sd1, sx2 * sd2, sx3 * sd3)
2136 };
2137}
2138
2139void SL::Offset(vector<Spline2>* splines, float offset)
2140{

Callers

nothing calls this directly

Calls 2

InvSqrtFastFunction · 0.85
Vec4fFunction · 0.85

Tested by

no test coverage detected