﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AMigius%2Forientation_matrix</id>
	<title>利用者:Migius/orientation matrix - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3AMigius%2Forientation_matrix"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Migius/orientation_matrix&amp;action=history"/>
	<updated>2026-04-19T22:25:26Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Migius/orientation_matrix&amp;diff=86485&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Migius/orientation_matrix&amp;diff=86485&amp;oldid=prev"/>
		<updated>2018-06-28T18:40:49Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 18:40時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Migius/orientation_matrix&amp;diff=86484&amp;oldid=prev</id>
		<title>wiki&gt;Migius: edit</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Migius/orientation_matrix&amp;diff=86484&amp;oldid=prev"/>
		<updated>2009-09-16T22:36:47Z</updated>

		<summary type="html">&lt;p&gt;edit&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;this page is dedicated to solve some issues in orientation-matrix in Blender &amp;lt;2.50&lt;br /&gt;
&lt;br /&gt;
2009.09.16: WIP &lt;br /&gt;
&lt;br /&gt;
=Intro=&lt;br /&gt;
Current implementation of orientation-matrix system in Blender is not reliable:&lt;br /&gt;
there are limitations / some nasty problems with mirrored/non-uniform-scaled geometry in Blender&lt;br /&gt;
&lt;br /&gt;
Perhaps, it is not a bug, but a system design side-effect: insufficient/incomplete representation method of object orientation data with &amp;quot;all-in-one loc/rot/scale-matrix&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=Orientation System=&lt;br /&gt;
Blender orientation-matrix is an [http://en.wikipedia.org/wiki/Orthogonal_matrix orthogonal_matrix]. Applying non-orthogonal-matrix (e.g. shear-matrix) doesn't work - it is on-the-fly transformed into orthogonal-matrix, so some information is lost or corrupted.&lt;br /&gt;
[[Image:orientation_matrix_01a.jpg|none|frame|RGB-boxes represent matrix (its XYZ-vectors)]]&lt;br /&gt;
&lt;br /&gt;
=get_matrix()=&lt;br /&gt;
WIP: implemented in PyAPI: getMatrix(object), object.matrixLocal(), object.matrixWorld()&lt;br /&gt;
&lt;br /&gt;
=apply_matrix=&lt;br /&gt;
==current implementation==&lt;br /&gt;
* used in: PyAPI.object.setMatrix(matrix), clear_parent(), apply_obmat()&lt;br /&gt;
* involved functions: matrix_to_euler() and matrix_to_scale()&lt;br /&gt;
* current implementation, issues:&lt;br /&gt;
** incorrect resulting object-orientation and/or object-scale, if given matrix is left-hand-oriented (mirrored objects = uneven number of negative scale factors)&lt;br /&gt;
** no support for shear-matrix&lt;br /&gt;
&lt;br /&gt;
*tests: &amp;quot;old&amp;quot; is produced with current apply_method, &amp;quot;new&amp;quot; with new method prototyped in python.&lt;br /&gt;
[[Image:orientation_matrix_apply_01a.jpg|none|frame|non-uniform scale + Z-rotation: correct.]]&lt;br /&gt;
[[Image:orientation_matrix_apply_01b.jpg|none|frame|negative scale + Z-rotation: correct.]]&lt;br /&gt;
[[Image:orientation_matrix_apply_01c.jpg|none|frame|non-uniform scale + XYZ-rotation: correct.]]&lt;br /&gt;
[[Image:orientation_matrix_apply_01d.jpg|none|frame|negative scale + XYZ-rotation: old_method fails.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==new method==&lt;br /&gt;
new method apply_matrix():&lt;br /&gt;
* relies on functions: matrix_to_scale() and matrix_to_euler()&lt;br /&gt;
* algorithmus:&lt;br /&gt;
*#input: orientation-matrix&lt;br /&gt;
*#analyze matrix if LeftHand-Matrix&lt;br /&gt;
*#extract scaleVector from matrix&lt;br /&gt;
*#if LeftHand-Matrix: convert scaleVector-&amp;lt;b&amp;gt;(X,Y,Z)&amp;lt;/b&amp;gt; to &amp;lt;b&amp;gt;(X,Y,-Z)&amp;lt;/b&amp;gt;&lt;br /&gt;
*#extract XYZ-euler from matrix&lt;br /&gt;
*#if scaleVector[Z] is negative: recalculate XYZ-euler in LeftHand-system&lt;br /&gt;
*#output: scaleVector and XYZ-euler&lt;br /&gt;
&lt;br /&gt;
===matrix_to_scale()===&lt;br /&gt;
implemented in arithb_c: Mat3ToSize(), Mat4ToSize()&lt;br /&gt;
&lt;br /&gt;
used in: matrix.getScale() WIP: existing method: matrix.scalePart()&lt;br /&gt;
&lt;br /&gt;
The new method respects negative scale-factors:&lt;br /&gt;
 calculate scale values from lengths of axis vectors&lt;br /&gt;
&lt;br /&gt;
 if uneven number of negative scale factors given, that means left-hand-matrix,&lt;br /&gt;
    then set scaleZ negative *)&lt;br /&gt;
todo: *) it is not a perfect solution yet. We need a method to estimate proper euler_angles relation to negative scaling (=mirrored orientation-axes).&lt;br /&gt;
&lt;br /&gt;
====--------------- Dependances:====&lt;br /&gt;
Mat3ToSize() : Referenced by:&lt;br /&gt;
 apply_targetless_ik(),&lt;br /&gt;
 ElementBoneSize(),&lt;br /&gt;
 ElementResize(),&lt;br /&gt;
 Mat3BlendMat3(),&lt;br /&gt;
 PoseBone_setLocalMatrix().&lt;br /&gt;
&lt;br /&gt;
Mat4ToSize() : Referenced by:&lt;br /&gt;
 actcon_get_tarmat(),&lt;br /&gt;
 apply_objects_visual_tx(),&lt;br /&gt;
 childof_evaluate(),&lt;br /&gt;
 constraintSizeLim(),&lt;br /&gt;
 do_strip_modifiers(),&lt;br /&gt;
 do_viewbuts(),&lt;br /&gt;
 followpath_evaluate(),&lt;br /&gt;
 generateSkeletonFromReebGraph(),&lt;br /&gt;
 Mat4BlendMat4(),&lt;br /&gt;
 Mat4ToDQuat(),&lt;br /&gt;
 pose_copy_menu(),&lt;br /&gt;
 PoseBone_setLocalMatrix(),&lt;br /&gt;
 PoseBone_setPoseMatrix(),&lt;br /&gt;
 posechannel_get_local_transform(),&lt;br /&gt;
 rotlike_evaluate(),&lt;br /&gt;
 rotlimit_evaluate(),&lt;br /&gt;
 sizelike_evaluate(),&lt;br /&gt;
 sizelimit_evaluate(),&lt;br /&gt;
 stretchto_evaluate(),&lt;br /&gt;
 trackto_evaluate(),&lt;br /&gt;
 transform_evaluate(),&lt;br /&gt;
 view3d_panel_object().&lt;br /&gt;
&lt;br /&gt;
===matrix_to_euler()===&lt;br /&gt;
implemented in arithb_c: Mat3ToEul(), mat3_to_eul2()&lt;br /&gt;
&lt;br /&gt;
The new method recognize mirrored matrices:&lt;br /&gt;
 get rotationPart from the matrix&lt;br /&gt;
&lt;br /&gt;
 left-hand-matrix detection (if negative scaleZ-factor there)&lt;br /&gt;
&lt;br /&gt;
 if right-hand-matrix, then standard calculation of euler_angles&lt;br /&gt;
 if left-hand-matrix, then alternative calculation&lt;br /&gt;
&lt;br /&gt;
====---------------- Dependences:====&lt;br /&gt;
Mat3ToEul() : Referenced by:&lt;br /&gt;
 apply_armature_pose2bones(),&lt;br /&gt;
 apply_obmat(),&lt;br /&gt;
 euler_rot(),&lt;br /&gt;
 Mat4ToEul(),&lt;br /&gt;
 Matrix_scalePart(),&lt;br /&gt;
 Matrix_toEuler(),&lt;br /&gt;
 Object_GetEuler(),&lt;br /&gt;
 Object_getSize(),&lt;br /&gt;
 QuatToEul(),&lt;br /&gt;
 read_videoscape_nurbs(),&lt;br /&gt;
 KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo(),&lt;br /&gt;
 KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo()&lt;br /&gt;
Mat4ToEul() : Referenced by:&lt;br /&gt;
 actcon_get_tarmat(),&lt;br /&gt;
 apply_objects_visual_tx(),&lt;br /&gt;
 childof_evaluate(),&lt;br /&gt;
 constraintRotLim(),&lt;br /&gt;
 do_strip_modifiers(),&lt;br /&gt;
 generateSkeletonFromReebGraph(),&lt;br /&gt;
 posechannel_get_local_transform(),&lt;br /&gt;
 KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo(),&lt;br /&gt;
 rotlike_evaluate(),&lt;br /&gt;
 rotlimit_evaluate(),&lt;br /&gt;
 transform_evaluate(),&lt;br /&gt;
 visualkey_get_value().&lt;br /&gt;
 used in: matrix.getEuler()&lt;br /&gt;
euler_rot : Referenced by:&lt;br /&gt;
 Euler_Rotate(),&lt;br /&gt;
 rotlike_evaluate().&lt;br /&gt;
&lt;br /&gt;
===Patch===&lt;br /&gt;
* [[media:orientation_matrix_arithb_c_patch.txt|arithb_c.patch]] (2009.03.25) - the patch for 2.48a svn rev.19305. Tested successfully on winXP32+scons+minGW&lt;br /&gt;
&amp;lt;!--* [http://4d-vectors.de/blend01/prog/matrix_labor.zip matrix_labor.zip] - a blend file with test environment--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Todo===&lt;br /&gt;
* prototyping and testing in python [[image:100%.png]]&lt;br /&gt;
* transcoding: Python to C [[image:100%.png]]&lt;br /&gt;
* check, if replacement in source code will brake existing functionality [[image:50%.png]]&lt;br /&gt;
* documentation, description [[image:50%.png]]&lt;br /&gt;
* report to bug-tracker [[image:100%.png]]&lt;br /&gt;
* report to patch-tracker [[image:00%.png]]&lt;br /&gt;
&lt;br /&gt;
=inverse_matrix=&lt;br /&gt;
==current implementation==&lt;br /&gt;
* needed in Blender in many places, intern and by PyAPI&lt;br /&gt;
* current implementation: matrix.inverse()&lt;br /&gt;
** mathematically correct, e.g. matrix.inverse().inverse() gives back the same matrix&lt;br /&gt;
** but geometrically not feasible in Blender, because resulting inverse_matrix is sometimes non-conform to Blender-orientation-system&lt;br /&gt;
** especially: if given matrix has rotation and non-uniform-scaling, final matrix become shear (non-orthogonal-matrix). Blender cant handle it correctly.&lt;br /&gt;
** tests: &amp;quot;old&amp;quot; is produced with current inverse_method, &amp;quot;new&amp;quot; with new method prototyped in python.&lt;br /&gt;
[[Image:orientation_matrix_inverse_01a.jpg|none|frame|if no_rotation: all perfect.]]&lt;br /&gt;
[[Image:orientation_matrix_inverse_01b.jpg|none|frame|if rotation: errors, old_method produces shear-matrix!]]&lt;br /&gt;
[[Image:orientation_matrix_inverse_01c.jpg|none|frame|negative_scale* + no_rotation: all perfect.]]&lt;br /&gt;
[[Image:orientation_matrix_inverse_01d.jpg|none|frame|negative_scale* + rotation: errors, shear-matrix!]]&lt;br /&gt;
&lt;br /&gt;
(*) tests made with new apply_matrix method, so negative_scale errors not appeared&lt;br /&gt;
&lt;br /&gt;
==new method (proposal)*==&lt;br /&gt;
&amp;lt;b&amp;gt;(*) Very early stage, WIP.&amp;lt;/b&amp;gt; I am not quite sure, if we even need this sort of functionality with inverse matrices. With current implementation i suspect some &amp;lt;b&amp;gt;issues with non-uniform-scaled rotated objects in parent-trees&amp;lt;/b&amp;gt;, but it needs more investigation.&lt;br /&gt;
&lt;br /&gt;
New method should solve some limitations / problems with mirrored/non-uniform-scaled parented geometry in Blender.&lt;br /&gt;
===Idea===&lt;br /&gt;
*new paradigm for handle with orientation_matrices: not mathematical, but geometrical oriented method&lt;br /&gt;
*the system must preserve critical orientation parameters like object's scale and orientation-angles, during entire transforming process, regardless of number and type of transformations&lt;br /&gt;
&lt;br /&gt;
===Goals===&lt;br /&gt;
bug-free, lossless, unambiguous and reversible transforming procedures, like:&lt;br /&gt;
*converting representation e.g. from &amp;quot;matrix&amp;quot; to &amp;quot;euler/scale&amp;quot;-form&lt;br /&gt;
*transforming orientation_matrix&lt;br /&gt;
*converting orientation_matrix to any level in parent-hierarchies, (= preserving orientation-data)&lt;br /&gt;
&lt;br /&gt;
===Pros===&lt;br /&gt;
more stable and reliable work with:&lt;br /&gt;
*(?) armatures&lt;br /&gt;
*(?) parenting-systems&lt;br /&gt;
*(?) import/export routines&lt;br /&gt;
*(?) animation (IPO-curves continuity in sizeXYZ, rotXYZ)&lt;br /&gt;
&lt;br /&gt;
===inverse_matrix()===&lt;br /&gt;
The new method is a geometrical equivalent of mathematical matrix.inverse() method:&lt;br /&gt;
*more visually comprehensible / more intuitive&lt;br /&gt;
*direct usable as object_matrix in Blender&lt;br /&gt;
 matrix split to two components: scale_vector and eulers&lt;br /&gt;
&lt;br /&gt;
 inverse_scale_vector = 1 / (scale_vector)&lt;br /&gt;
 [1, 4, -2] -&amp;gt; [1, 0.25, -0.5]&lt;br /&gt;
 [1, 0.5, -2] -&amp;gt; [1, 2, -0.5]&lt;br /&gt;
&lt;br /&gt;
 inverse_eulers = (eulers)* -1&lt;br /&gt;
 [30,0,0] -&amp;gt; [-30,0,0]&lt;br /&gt;
 [30,-20,0] -&amp;gt; [-30,20,0]&lt;br /&gt;
&lt;br /&gt;
 for 4x4_matrix: inverse_location_vector = (loc_vector)* -1&lt;br /&gt;
 [1, 4, -2] -&amp;gt; [-1, -4, 2]&lt;br /&gt;
&lt;br /&gt;
 re-generate inverted_matrix on basis of inverse_(loc/rot/scale)_vectors&lt;br /&gt;
&lt;br /&gt;
===Patch===&lt;br /&gt;
Although python prototype evaluated successfully, writing a patch in C will take a while, cause it needs a deeper analyze of dependencies in source code. Probably inverseMatrix calculation is not exclusively used for object orientation purposes.&lt;br /&gt;
&lt;br /&gt;
===Todo===&lt;br /&gt;
* prototyping and testing in python [[image:100%.png]]&lt;br /&gt;
* transcoding: Python to C [[image:00%.png]]&lt;br /&gt;
* check, if replacement in source code will brake existing functionality [[image:25%.png]]&lt;br /&gt;
* documentation, description [[image:50%.png]]&lt;br /&gt;
* report to bug-tracker [[image:00%.png]]&lt;br /&gt;
* report to patch-tracker [[image:00%.png]]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Migius</name></author>
		
	</entry>
</feed>