1.8 KiB
1.8 KiB
Documentation
- Class name: Vec2ToScalarBinaryOperation
- Category: math/vec2
- Output node: False
- Repo Ref: https://github.com/evanspearman/ComfyMath
Vec2ToScalarBinaryOperation节点旨在对二维向量执行二元运算,将其转换为标量值。它将向量算术的本质封装在单一操作中,提供了一种简化的方式来操作向量数据并派生出有意义的标量输出。
Input types
Required
- op
- 参数'op'至关重要,因为它决定了要在输入向量上执行的二元运算类型。它决定了将应用的数学逻辑,从而影响最终的标量结果。
- Comfy dtype: str
- Python dtype: str
- a
- 参数'a'表示二元运算中的第一个向量。它是节点功能的一个基本组成部分,因为运算的结果取决于此向量内的值。
- Comfy dtype: Vec2
- Python dtype: numpy.ndarray
- b
- 参数'b'表示参与二元运算的第二个向量。它的值在形成操作结果方面同样重要,确保对向量对进行全面分析。
- Comfy dtype: Vec2
- Python dtype: numpy.ndarray
Output types
- result
- 'result'输出是从输入向量上执行的二元运算派生的标量值。它是节点处理的最终结果,代表了数学运算后的最终输出。
- Comfy dtype: FLOAT
- Python dtype: float
Usage tips
- Infra type: CPU
Source code
class Vec2ToScalarBinaryOperation:
@classmethod
def INPUT_TYPES(cls) -> Mapping[str, Any]:
return {'required': {'op': (list(VEC_TO_SCALAR_BINARY_OPERATION.keys()),), 'a': DEFAULT_VEC2, 'b': DEFAULT_VEC2}}
RETURN_TYPES = ('FLOAT',)
FUNCTION = 'op'
CATEGORY = 'math/vec2'
def op(self, op: str, a: Vec2, b: Vec2) -> tuple[float]:
return (VEC_TO_SCALAR_BINARY_OPERATION[op](numpy.array(a), numpy.array(b)),)