Skip to content

✨ new quaternion gates#3563

Open
Strand8319 wants to merge 2 commits intowiremod:masterfrom
Strand8319:quaternion-gates
Open

✨ new quaternion gates#3563
Strand8319 wants to merge 2 commits intowiremod:masterfrom
Strand8319:quaternion-gates

Conversation

@Strand8319
Copy link
Copy Markdown
Contributor

No description provided.

@llysdal
Copy link
Copy Markdown
Member

llysdal commented Apr 10, 2026

image when making a constant value, even if you set it as a quaternion it changes back to 4D vector every time you make a change, which is a bit annoying

return Angle(tonumber(p),tonumber(y),tonumber(r))
end
end
function parsers.QUATERNION( val )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps this match function should be made slightly different from the 4d vector one? maybe 1, 1i, 1j, 1k should parse as a quat? - open to better solutions, it would just be nice to have something that parses as a quat and doesnt change to 4d vector every time you change it

},
}

WireLib.Quaternion = {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

}

GateActions["quaternion_qmod"] = {
name = "qMod",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason this is called qMod rather than just Mod?

}

GateActions["quaternion_nlerp"] = {
name = "Nlerp",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe descriptions on slerp and nlerp to describe the difference? we have comments for every function in the wirelib quaternion "library", we could copy those in as gate descriptions

}

GateActions["quaternion_qrotation"] = {
name = "qRotation (Axis + Angle)",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, why qRotation rather than rotation?

Comment on lines +684 to +765
GateActions["quaternion_qi"] = {
name = "qi()",
inputs = {},
inputtypes = {},
outputtypes = { "QUATERNION" },
output = function(gate)
local Q = getQ()
return Q and Q.New(0, 1, 0, 0) or { 0, 1, 0, 0 }
end,
label = function(Out)
return "qi() = " .. qfmt(Out)
end
}

GateActions["quaternion_qi_num"] = {
name = "qi(n)",
inputs = { "N" },
inputtypes = { "NORMAL" },
outputtypes = { "QUATERNION" },
output = function(gate, N)
local Q = getQ()
return Q and Q.New(0, N or 0, 0, 0) or { 0, N or 0, 0, 0 }
end,
label = function(Out, N)
return "qi(" .. nfmt(N or 0) .. ") = " .. qfmt(Out)
end
}

GateActions["quaternion_qj"] = {
name = "qj()",
inputs = {},
inputtypes = {},
outputtypes = { "QUATERNION" },
output = function(gate)
local Q = getQ()
return Q and Q.New(0, 0, 1, 0) or { 0, 0, 1, 0 }
end,
label = function(Out)
return "qj() = " .. qfmt(Out)
end
}

GateActions["quaternion_qj_num"] = {
name = "qj(n)",
inputs = { "N" },
inputtypes = { "NORMAL" },
outputtypes = { "QUATERNION" },
output = function(gate, N)
local Q = getQ()
return Q and Q.New(0, 0, N or 0, 0) or { 0, 0, N or 0, 0 }
end,
label = function(Out, N)
return "qj(" .. nfmt(N or 0) .. ") = " .. qfmt(Out)
end
}

GateActions["quaternion_qk"] = {
name = "qk()",
inputs = {},
inputtypes = {},
outputtypes = { "QUATERNION" },
output = function(gate)
local Q = getQ()
return Q and Q.New(0, 0, 0, 1) or { 0, 0, 0, 1 }
end,
label = function(Out)
return "qk() = " .. qfmt(Out)
end
}

GateActions["quaternion_qk_num"] = {
name = "qk(n)",
inputs = { "N" },
inputtypes = { "NORMAL" },
outputtypes = { "QUATERNION" },
output = function(gate, N)
local Q = getQ()
return Q and Q.New(0, 0, 0, N or 0) or { 0, 0, 0, N or 0 }
end,
label = function(Out, N)
return "qk(" .. nfmt(N or 0) .. ") = " .. qfmt(Out)
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we have these gates? couldnt you get the same experience by just using a constant value?

full list of gates i think could be trimmed as theyre replaceable by constant value:
quat() - quaternion_quat0
qi() - quaternion_qi
qj() - quaternion_qj
qk() - quaternion_qk

and some im not so sure about,, i dont see the usage - but im not super versed with quaternions
Identity - quaternion_ident
qi(n) - quaternion_qi_num
qj(n) - quaternion_qj_num
qk(n) - quaternion_qk_num

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants