ベクトルの特定成分を取り出す
視線ベクトルについて、特定軸方向の成分を取り出します。 大きさは任意で変更できます。
この機構をベースとしています。
参照する視線を持つエンティティを<object>とします。
座標の基準点を<coordinates>とします。
ベクトルの大きさをrとします。
①x成分の取り出し
/execute
as <target>
at @s
positioned 0.0 0.0 0.0
positioned ^ ^ ^-2
positioned ~ 0.0 0.0
positioned ^ ^ ^1
facing 0.0 0.0 0.0
positioned <coordinates>
positioned ^ ^ ^r/2
rotated as @s
positioned ^ ^ ^r/2
run
<command>
②y成分の取り出し
/execute
as <target>
at @s
rotated ~180 ~
positioned <coordinates>
positioned ^ ^ ^r/2
rotated as @s
positioned ^ ^ ^r/2
run
<command>
③z成分の取り出し
/execute
as <target>
at @s
positioned 0.0 0.0 0.0
positioned ^ ^ ^-2
positioned 0.0 0.0 ~
positioned ^ ^ ^1
facing 0.0 0.0 0.0
positioned <coordinates>
positioned ^ ^ ^r/2
rotated as @s
positioned ^ ^ ^r/2
run
<command>