首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >微软SkiaSharp中的惊天Bug

微软SkiaSharp中的惊天Bug

原创
作者头像
秦建辉
发布2025-05-13 10:56:58
发布2025-05-13 10:56:58
2541
举报
文章被收录于专栏:杂谈杂谈

SkiaSharp版本:3.119.0

SKPoint的Reflect方法计算有问题。

原始错误代码:

代码语言:csharp
复制
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);
}

正确代码:

代码语言:csharp
复制
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 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档