SkiaSharp版本:3.119.0
SKPoint的Reflect方法计算有问题。
原始错误代码:
public static SKPoint Reflect (SKPoint point, SKPoint normal)
{
var dot = point.x * point.x + point.y * point.y;
return new SKPoint (
point.x - 2.0f * dot * normal.x,
point.y - 2.0f * dot * normal.y);
}
正确代码:
public SKPoint Reflect (SKPoint normal)
{
SKPoint normalizedNormal = Normalize (normal); // 法向量归一化
var dot = x * normalizedNormal.x + y * normalizedNormal.y; // 计算点积
return new SKPoint (
x - 2.0f * dot * normalizedNormal.x,
y - 2.0f * dot * normalizedNormal.y);
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。