WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 09-11-2012, 09:53 AM
nabrahamson nabrahamson is offline
Member
 
Join Date: Sep 2011
Posts: 36
I'm not sure if it's clear on what I'm trying to do. The first attached picture contains two coordinate axis drawn on the screw. The first one replicates the coordinate system that is created in inspector with axis colored red, green and blue. The second coordinate system shares its origin with the first, but is drawn to represent the global x,y,z coordinate system.

The basis for the first coordinate system is from the matrix created from the command:

Code:
<node3d>.getMatrix(viz.ABS_GLOBAL, node='Inst-1430')
[ 0.000000, -0.004384, -0.008988, 0.000000,
  -0.000000, 0.008988, -0.004384, 0.000000,
  0.010000, 0.000000, 0.000000, 0.000000,
  -0.381762, -0.560596, -2.557960, 1.000000 ]
So the x-coordinate is drawn by creating a vector using the 4th and 1st row of this matrix and scaled (just so they are visible). And the y (elements 5-7 of the matrix) and z (elements 9-11 of the matrix) coordinates are created using a similar method.

Code:
[-0.381762 + 0.0,  -0.560596 + (-0.004384), -2.557960 + (-0.008988)]
So the point I used to create the y coordinate is called y_trans.
I made the assumption that using the command

Code:
moveaction = vizact.moveTo(y_trans, mode = viz.ABS_GLOBAL)
<node3d>.addAction(moveaction)
Would move the screw to the endpoint of the green axis. Instead, that command moves the screw to the position shown in the second attachment. Is this because the transformation matrix given by the getMatrix command is applied to the node before the translation of the moveTo command?

Here is the complete code I am using to draw those axis:

Code:
def draw_line(p, axis, color):
	viz.startLayer(viz.LINES)
	viz.lineWidth(3)
	viz.vertexColor(color)
	viz.vertex(p)
	viz.vertex(axis)
	viz.endLayer()
	
def debug_script():
	#Data is a helper class that creates a global object to share all of our object data between scripts
        part = Data.getData().parts_list[0]
       	global screw
	screw = part.getChildren()[0]
	point = [-0.381762, -0.560596, -2.557960]
	x_axis = [ 0.000000, -0.004384, -0.008988]
	y_axis = [  -0.000000, 0.008988, -0.004384]
	z_axis = [ -0.01, -0.00, 0.00]
	
	x_global = [1.0, 0.0, 0.0]
	y_global = [0.0, 1.0, 0.0]
	z_global = [0.0, 0.0, 1.0]
	
	global x_trans
	x_trans = [point[i] + x_axis[i]*30 for i in range(3)]
	global y_trans
	y_trans = [point[i] + y_axis[i]*30 for i in range(3)]
	global z_trans
	z_trans = [point[i] + z_axis[i]*30 for i in range(3)]
	
	draw_line(point, x_trans, [1,0,0])
	draw_line(point, y_trans, [0,1,0])
	draw_line(point, z_trans, [0,0,1])
	
	x_global_axis = [point[i] + x_global[i] for i in range(3)]
	y_global_axis = [point[i] + y_global[i] for i in range(3)]
	z_global_axis = [point[i] + z_global[i] for i in range(3)]
	
	draw_line(point, x_global_axis, [1,1,0])
	draw_line(point, y_global_axis, [1,0,1])
	draw_line(point, z_global_axis, [0,1,1])
Attached Thumbnails
Click image for larger version

Name:	local_global_axis.png
Views:	5556
Size:	297.6 KB
ID:	524   Click image for larger version

Name:	rel_global.png
Views:	5486
Size:	202.0 KB
ID:	525  
__________________
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Haptic touch texture coordinates yth Vizard 0 06-02-2012 04:40 AM
How do coordinates in IS900 thransform into coordinates in vizard's world jacky Vizard 1 08-11-2011 11:44 AM
child-objects in VRML-file all have the same coordinates Sven Vizard 4 06-09-2010 03:07 AM
viz.vertex coordinates lilio Vizard 6 05-16-2009 05:36 PM
Object rotating around world axis, not own axis tacbob Vizard 1 02-15-2007 10:12 AM


All times are GMT -7. The time now is 12:39 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC