%------------------------------------------------------% %---Helix curve (parametrized on arc lenght)-----------% %---and intrinsic vectors------------------------------% %------------------------------------------------------% DEF helix (a,b::IsReal) = WHERE u = ID / SQRT ~ K:(a*a + b*b) END; DEF helixtangent (a,b::IsReal) = AA:D:(helix:); DEF helixnormal (a,b::IsReal) = K:((a*a + b*b)/a) scalarVectProd AA:(D ~ D):(helix:); DEF helixbinormal (a,b::IsReal) = helixtangent: VectProd helixnormal:; DEF helixcurvatureCenter (a,b::IsReal) = helix: vectSum (K:((sqr:a + sqr:b)/a) scalarVectProd helixnormal:) ; DEF helixOsculCircle (a,b,s::IsReal) = (T:<1,2,3>:center ~ Rotn:):circle WHERE circle = MAP:((circle3D ~ radius):):(intervals:(2*PI):24), angle = (- ~ ACOS ~ InnerProd):>, axis = CONS:(helixnormal:):s, center = CONS:(helixCurvatureCenter:):s, ortho = CONS:(helixbinormal:):s END; DEF circle3D (r::IsReal) = [K:r * COS, K:r * SIN, K:0] ~ s1; DEF radius (a,b,s::IsReal) = (VectNorm ~ VectDiff): < CONS:(helix:):s, CONS:(helixcurvatureCenter:):s >; DEF CurveGraph (f::IsSeqOf:IsFun) = MAP:(CONS:f ~ s1):(intervals:(6*PI):90); DEF assembly = STRUCT:< (CurveGraph ~ helix):<1,2>, (CurveGraph ~ helixcurvatureCenter):<1,2>, (JOIN ~ helixOsculCircle):<1,2, 2*PI> >; DEF out = (STRUCT ~ [ID, BOX:<1,2>]):assembly