Blame synfig-core/doc/tangentproblem.txt

Nikita Kitaev dc5e35
THE PROBLEM OF THE TANGENT OF THE BLINES UNDER BONE INFLUENCE
Nikita Kitaev dc5e35
=============================================================
Nikita Kitaev dc5e35
Tangents are relative to vertices in any of its definitions (radius, angle)
Nikita Kitaev dc5e35
or (x,y). As the transformation performed by bones is prepaed to work on
Nikita Kitaev dc5e35
global coordinates vertices, the tangent transformation can not be directly
Nikita Kitaev dc5e35
transformed by bones in that way.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
There are some solutions to solve that:
Nikita Kitaev dc5e35
1) 	The solution that Anime Studio gives to the tangents: It doesn't
Nikita Kitaev dc5e35
	have real tangents but calculated ones based on the neighbour vertices
Nikita Kitaev dc5e35
	position and a parameter called 'curvature'.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
2) 	As well the tangents are relative to the vertex it belongs to, we
Nikita Kitaev dc5e35
	need to convert the tangent to global coordinates, transform it by the
Nikita Kitaev dc5e35
	bone(s) influence and then convert it to local coordinates again.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
luz.paz 99f3ef
1) PROPOSAL FOR TANGENTS 'CALCULATED' BASED ON NEIGHBOR VERTICES
Nikita Kitaev dc5e35
================================================================
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
	param						convert type					value type
Nikita Kitaev dc5e35
	-----						------------					----------
Nikita Kitaev dc5e35
	Tangent                     AverageTangent					Vector
Nikita Kitaev dc5e35
		Current					BoneInfluence					Vector
Nikita Kitaev dc5e35
		Next					BoneInfluence					Vector
Nikita Kitaev dc5e35
		Previous				BoneInfluence					Vector
Nikita Kitaev dc5e35
		Link					Vector							Vector
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
'Current' is the current vertex in the bline (where the tangent lies) it is not a parameter
Nikita Kitaev dc5e35
'Next' is the next vertex in the bline relative to Current
Nikita Kitaev dc5e35
'Previous' it is the previous vertex in the bline relative to Current.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Resulting Tangent (radius, angle) is defined by:
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Let's call: V=Current-(Next+Previous)*0.5
Nikita Kitaev dc5e35
Let's call: V0=Current.Link-(Next.Link+Previous.Link)*0.5
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Radius:
Nikita Kitaev dc5e35
radius = Link.radius
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Angle:
Nikita Kitaev dc5e35
angle=atan2(V.x,V.y) - (atan2(V0.x,V0.y)-Link.angle)
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
When the user manipulates the tangent duck it modifies Link as an offset.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Problems:
Nikita Kitaev dc5e35
-Insert a vertex
Nikita Kitaev dc5e35
-Vertex "on", "off"
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
2) PROPOSAL FOR TANGENTS IN GLOBAL COORDINATES
Nikita Kitaev dc5e35
==============================================
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
Given a vertex V and a tangent T and a transformed position of the vertex
Nikita Kitaev dc5e35
after bone influence V', calculate the transformed position of the tangent.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
global position of the tangent:
Nikita Kitaev dc5e35
TG=V+T
Nikita Kitaev dc5e35
TG'=V'+T'
Nikita Kitaev dc5e35
luz.paz 99f3ef
T'=TG'-V' = (V+T)' -V' where ' means transformed by bones.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
	param						convert type					value type
Nikita Kitaev dc5e35
	-----						------------					----------
Nikita Kitaev dc5e35
	Tangent						BoneTangent						Vector
Nikita Kitaev dc5e35
		Bone Weight List		List							Static List
Nikita Kitaev dc5e35
		Link (T)												Vector
Nikita Kitaev dc5e35
		Vertex (V)												Vector
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
It is reasonable that the Bone Weight List is the same for both parameters.
Nikita Kitaev dc5e35
Nikita Kitaev dc5e35
When user manipulates the tangent duck it modifies the parameter T.