Skip to content

✨ new quaternion gates#3563

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

✨ new quaternion gates#3563
Strand8319 wants to merge 3 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

don't sure would it be comfortable to use then since every type doesn't user chars to determine axis

},
}

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

well, every gate category has identity, mb I'll leave it, the rest goes to void

@Strand8319
Copy link
Copy Markdown
Contributor Author

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

same goes with angles and vectors
everytime you change angle it becomes vector

@Strand8319 Strand8319 force-pushed the quaternion-gates branch 2 times, most recently from 35f60b0 to e71f36d Compare April 12, 2026 10:51
- remove some gates
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