Coordinate math help for logic?
Been working on some logic for a game, I'm not strong in math but I sorta know what needs to be done.
How would you find (x2, y2, z2) given (x1,y1,z1), the angle, and the distance between the points? Is there a formula?
Help is greatly appreciated, thank you.
-
There are such formulas on the internet you can find. The calculator doesn't have sin, cos, and tan, though there are some chips people have made that let you use those functions.
I would probably do it a different way, though. It's a little complicated conceptually, but should work perfectly. Create a block with a tag grouped with it--central but moved further away in one direction. This will be your readout. Wire its scene transform into a chip outside of that group. You can split it (add a splitter, wire the scene transform into it) to get just the position if you like.
Now, outside that group make an emitter, and link it to that cube group. In the last tab, turn on "emit wires" so that the logic stays intact. You probably want it in "once" mode so it just emits a single instance.
Now, we need to make a scene transform so we can set where the object will be emitted and its rotation. To do that, add a combiner, and set it to "scene transform" mode. Wire the value you want for (x1, y1, z1) into the position input. Wire the rotation you want into the rotation input (if you don't have a rotation fat wire, you can make one with another combiner).
Now, when you turn on the emitter, it will spit out that cube at the correct position and rotation, and the tag will give you the position of that rotated point.
I know that all sounds a bit complicated, but it's probably actually cheaper than the sin/cos/tan chips. So up to you. -
Hi TAPgiles, thanks much for replying here.
If I understand correctly, the tag that is grouped into the block servers as the second point, as it will maintain orientation in the group?
Unfortunately this is something I have tried. I am sorry for leaving info out as I tried this method a bit after posting here,
basically I need this same thing to work, but the whole group rotates around the center of the block using a joystick rotator. When the joystick rotator is placed outside the group, the pivot point is locked to the center of the block and tag.
Another thing I tried was using a teleporter. I had a second block outside of the first, that teleports to the position and orientation of the first. This works great up close, but when the distance is great, the teleport unexpectedly lags behind, causing an inaccurate coordinate.
I've done a lot of research on what the math may be like, but haven't come across this though I don't even know what this problem would be named.
Again I am very thankful you have replied to this. If I am missing something or if there's a hacky solution please let me know. -
Ah, I see. I made a joystick rotator a while back. Maybe that one will help? https://indreams.me/element/oMmwiKtDjTq
You could just surface-snap a tag into that block and use its scene transform output as before.
If you want it to be relative to the puppet's position or something, teleporting and emitting do lag by 1 frame. So instead, you could subtract the rotated position from the pivot position. Then add the result to the puppet's position. Then there's no need for teleporting or anything.
Also, in case you weren't aware, you can use a single calculator to subtract XYZ from XYZ, etc. So this makes it very easy to do arithmetic with fat wires like positions. -
Problem solved! It's just as you said, I can move the tag position gizmo away from the block to receive the required result. All this time working on this silly thing and the thought never crossed my mind.
I do know of calculating fat wires, but I'm sure the frame delay info on the tp will come in handy.
Thanks again :)
Please sign in to leave a comment.