11'''
2- Created on Apr 14, 2014
32
4- @author: Patrick
3+
4+ Copyright (c) 2014-2015 Patrick Moore
5+ patrick.moore.bu@gmail.com
6+
7+
8+ Created by Patrick Moore for Blender, with adaptation of works by Christoph Gohlke, Nghia Ho
9+
10+ This program is free software: you can redistribute it and/or modify
11+ it under the terms of the GNU General Public License as published by
12+ the Free Software Foundation, either version 3 of the License, or
13+ (at your option) any later version.
14+
15+ This program is distributed in the hope that it will be useful,
16+ but WITHOUT ANY WARRANTY; without even the implied warranty of
17+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+ GNU General Public License for more details.
19+
20+ You should have received a copy of the GNU General Public License
21+ along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
23+
24+
25+ Parts of this code are adapted from transformations.py by Christoph Gohlke
26+ http://www.lfd.uci.edu/~gohlke/code/transformations.py
27+
28+ The following copyright and information is attached
29+ # Copyright (c) 2006-2015, Christoph Gohlke
30+ # Copyright (c) 2006-2015, The Regents of the University of California
31+ # Produced at the Laboratory for Fluorescence Dynamics
32+ # All rights reserved.
33+ #
34+ # Redistribution and use in source and binary forms, with or without
35+ # modification, are permitted provided that the following conditions are met:
36+ #
37+ # * Redistributions of source code must retain the above copyright
38+ # notice, this list of conditions and the following disclaimer.
39+ # * Redistributions in binary form must reproduce the above copyright
40+ # notice, this list of conditions and the following disclaimer in the
41+ # documentation and/or other materials provided with the distribution.
42+ # * Neither the name of the copyright holders nor the names of any
43+ # contributors may be used to endorse or promote products derived
44+ # from this software without specific prior written permission.
45+ #
46+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
47+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
50+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
51+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
52+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
53+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
54+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
56+ # POSSIBILITY OF SUCH DAMAGE.
557'''
58+
59+
660from numpy .ma .core import fmod
761bl_info = {
862 "name" : "Complex Alignment" ,
@@ -64,7 +118,6 @@ def draw_3d_points(context, points, color, size):
64118 bgl .glEnd ()
65119 return
66120
67-
68121def draw_3d_points_revised (context , points , color , size ):
69122 region = context .region
70123 region3d = context .space_data .region_3d
@@ -108,7 +161,7 @@ def draw_3d_text(context, font_id, text, vec):
108161 blf .position (font_id , x + 3.0 , y - 4.0 , 0.0 )
109162 blf .draw (font_id , text )
110163
111-
164+ #http://www.lfd.uci.edu/~gohlke/code/transformations.py
112165def quaternion_matrix (quaternion ):
113166 """Return homogeneous rotation matrix from quaternion.
114167
@@ -135,7 +188,7 @@ def quaternion_matrix(quaternion):
135188 [ q [1 , 3 ]- q [2 , 0 ], q [2 , 3 ]+ q [1 , 0 ], 1.0 - q [1 , 1 ]- q [2 , 2 ], 0.0 ],
136189 [ 0.0 , 0.0 , 0.0 , 1.0 ]])
137190
138-
191+ #http://www.lfd.uci.edu/~gohlke/code/transformations.py
139192def vector_norm (data , axis = None , out = None ):
140193 """Return length, i.e. Euclidean norm, of ndarray along axis.
141194
@@ -173,7 +226,8 @@ def vector_norm(data, axis=None, out=None):
173226 data *= data
174227 np .sum (data , axis = axis , out = out )
175228 np .sqrt (out , out )
176-
229+
230+ #http://www.lfd.uci.edu/~gohlke/code/transformations.py
177231def affine_matrix_from_points (v0 , v1 , shear = True , scale = True , usesvd = True ):
178232 """Return affine transform matrix to register two point sets.
179233
@@ -290,6 +344,7 @@ def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True):
290344
291345
292346#Preferences
347+
293348class AlignmentAddonPreferences (AddonPreferences ):
294349 # this must match the addon name, use '__package__'
295350 # when defining this in a submodule of a python package.
@@ -354,7 +409,6 @@ def draw(self, context):
354409 layout .prop (self , "target_d" )
355410 layout .prop (self , "align_meth" )
356411
357-
358412class ComplexAlignmentPanel (bpy .types .Panel ):
359413 """UI for ICP Alignment"""
360414 #bl_category = "Alignment"
@@ -421,7 +475,6 @@ def draw(self, context):
421475 row .prop (settings , 'target_d' )
422476
423477
424-
425478#modified from http://nghiaho.com/?page_id=671
426479def rigid_transform_3D (A , B ):
427480 assert len (A ) == len (B )
@@ -961,8 +1014,7 @@ def invoke(self, context, event):
9611014 context .window_manager .modal_handler_add (self )
9621015 self ._handle = bpy .types .SpaceView3D .draw_handler_add (draw_callback_px , (self , context ), 'WINDOW' , 'POST_PIXEL' )
9631016 return {'RUNNING_MODAL' }
964-
965-
1017+
9661018class OJECT_OT_icp_align (bpy .types .Operator ):
9671019 """Uses ICP alignment to iteratevely aligne two objects"""
9681020 bl_idname = "object.align_icp"
0 commit comments