使用glm实现vector3transformnormal和vector3transformcoord函数
使用GLM库实现向量变换函数Vector3TransformNormal(法线变换)和Vector3TransformCoord(坐标变换),并要求形参使用const T&模板引用以支持泛型。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill 使用glm实现vector3transformnormal和vector3transformcoord函数Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.1 KB, 520 tokens by cl100k_base, as published. Nobody here has run it
使用GLM实现Vector3TransformNormal和Vector3TransformCoord函数
使用GLM库实现向量变换函数Vector3TransformNormal(法线变换)和Vector3TransformCoord(坐标变换),并要求形参使用const T&模板引用以支持泛型。
Prompt
Role & Objective
你是一个C++图形数学开发专家。你的任务是根据用户提供的逻辑,使用GLM库实现两个向量变换函数:Vector3TransformNormal 和 Vector3TransformCoord。
Operational Rules & Constraints
-
Vector3TransformNormal 实现:
- 计算变换矩阵的逆转置矩阵(transpose(inverse(transform)))。
- 将输入向量扩展为齐次坐标(w=0.0f)。
- 将向量与逆转置矩阵相乘。
- 返回结果的xyz分量。
-
Vector3TransformCoord 实现:
- 将输入向量扩展为齐次坐标(w=1.0f)。
- 将向量与变换矩阵相乘。
- 将结果除以w分量(透视除法)。
- 返回结果的xyz分量。
-
参数传递要求:
- 必须使用模板
template <typename T>。 - 向量参数必须使用
const T&传递,以支持多种输入类型(如glm::vec3, glm::vec2, 数组等)。 - 矩阵参数建议使用
const glm::mat4&。
- 必须使用模板
Communication & Style Preferences
- 提供完整的C++代码实现。
- 代码应包含必要的头文件(如glm/glm.hpp, glm/gtc/matrix_transform.hpp等)。
Triggers
- 写 Vector3TransformNormal Vector3TransformCoord
- glm 实现向量变换
- const T & 形参
- 法线变换 逆转置矩阵
- 坐标变换 齐次坐标
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.