View Full Version : Get a coordinate between to points

 KIIIA12 December 2011, 11:14 PMHello, i am currently working on a script where i need to place vertices on the straight line between two points. The vertices need to be placed not only at the centerpoint, but at any position on this line i specify. I tried lots of things, but i can only get it to work right with the center value strangely, which looks like this: #Get Coordinate at between two coordinates according to a factor def get_point_inbetween(self,obj_1_ws_coords, obj_2_ws_coords, summand ): #Calculation coord_x = (obj_1_ws_coords[0] + obj_2_ws_coords[0]) / 2 + summand coord_y = (obj_1_ws_coords[1] + obj_2_ws_coords[1]) / 2 + summand coord_z = (obj_1_ws_coords[2] + obj_2_ws_coords[2]) / 2 + summand return [coord_x, coord_y, coord_z] Only when summand is 0 it works properly.....but summand is ment to be a value letting me "slide" along the line! Anybody an idea how to achieve the correct result?
KIIIA
12 December 2011, 12:21 AM
I found out:

#Get Coordinate at between two coordinates according to a factor
def get_point_inbetween(self,obj_1_ws_coords, obj_2_ws_coords, factor ):

#Calculation
coord_x = obj_1_ws_coords[0] + factor *(obj_2_ws_coords[0] - obj_1_ws_coords[0])
coord_y = obj_1_ws_coords[1] + factor *(obj_2_ws_coords[1] - obj_1_ws_coords[1])
coord_z = obj_1_ws_coords[2] + factor *(obj_2_ws_coords[2] - obj_1_ws_coords[2])

return [coord_x, coord_y, coord_z]

...does the job for me!
Thread can be closed....

CGTalk Moderation
12 December 2011, 12:21 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.

1