Notifications
Clear all

[Closed] "pretranslate" for a point3 value?

I’m probably missing something obvious here, but hopefully someone can help. If I want to adjust a point3 value, say [10, 20, 30], against a given coordSys… how do I do it?

It’s easy to do with a matrix3 value using pretranslate, and it it’s an actual scene node I can just move it. But with a point3 value I seem to only be able to adjust the position in world space. What am I missing?

5 Replies
1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

Are you try coordsys context?

Maybe I did a bad job explaining what I need. Okay, take this as an example:

-- Create a point helper with a random position and rotation
p = point()
for a = 1 to 3 do
(
	p.rotation.controller[a].value = random 0 180
	p.pos.controller[a].value = random 0 10
)

-- Specify a position in space
startPos = [10, 10, 10]

-- Offset that position in the direction of the x-axis of the point helper
--endPos = in coordsys p.transform <offset> startPos [10, 0, 0]

What do I put in place of <offset>? Or is this not something that can be done directly? I’m having a “how do I shot web?” moment here…

Thake a look this example


fn offsetPos node tm offset affectRot:on =
(
	tm.row4 = node.pos
	newTm = pretranslate tm offset
	if affectRot then node.transform = newTm else node.pos = newTm.row4
)
-- example
delete objects
pnt_dir = point cross:off axistripod:on pos:[30,50,5] rotation:(quat 0 -0.350382 0 0.936607) size:10 wirecolor:red
pnt_start = point cross:off axistripod:on pos:[10,10,10] size:10 wirecolor:yellow
py1 = Pyramid width:5 depth:5 height:10 pos:pnt_start.pos
py2 = copy py1
--offset "py1" pos only
offsetPos py1 pnt_dir.transform [10,0,0] affectRot:off 
-- offset and affect rotation py2
offsetPos py2 pnt_dir.transform [30,0,0]

With geometry you can just use “in coordsys tm move”, but I was able to modify the function for working with point3 values. Thanks!

fn offsetP3 p3 tm offset =
(
	tm.row4 = p3
	newTM = preTranslate tm offset
	p3 = tm.row4
)

the math formula is

((point * inverse tm) + offset) * tm