示例#1
0
    def curvature(self, seg, u):
        '''Returns Frenet curvature of spline at parameter u'''

        # https://en.wikipedia.org/wiki/Frenet-Serret_formulas
        vel = self.velocity(seg, u)
        return Vector3.cross(vel, self.acceleration(
            seg, u)).length() / (vel.length())**3
示例#2
0
    def get(self, t, scale):
        t = float(scale * t)

        x_basis = self.p1 - self.p0
        y_basis = x_basis.length() * Vector3.cross(x_basis, Vector3.k()).normalize()
        basis = Mat2x2.fromvectors(
            x_basis, 
            y_basis
        )

        transformed_v0 = (basis * self.v0).normalize()
        transformed_v1 = (basis * self.v1).normalize()

        slope_0 = transformed_v0.y / transformed_v0.x
        slope_1 = transformed_v1.y / transformed_v1.x

        spline =  Vector3(
            t,
            (self.H2(t) * slope_0) + (self.H3(t) * slope_1)
        )

        # f.write("{},{}\n".format(
        #     spline.x, spline.y 
        # ))

        spline_der = Vector3(
            scale,
            (self.d_H2(t, scale) * slope_0) + (self.d_H3(t, scale) * slope_1)
        )


        return ((basis * spline) + self.p0, (basis * spline_der))