游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1125|回复: 2

在计算插值的时候,求余为什么要加1啊

[复制链接]

3

主题

9

帖子

9

积分

新手上路

Rank: 1

积分
9
发表于 2006-1-24 00:05:00 | 显示全部楼层 |阅读模式
suppose you want to move an object from one point to another over a period of 1,000 milliseconds. The following code (processed once per frame) will accomplish this, continuously looping back from the end to the start of the path in an endless cycle.

// vecPoints[2] = path's starting and ending coordinate vectors
// Every frame, use the following code to position an object
// along the straight path based on the current time.
float Scalar = (float)(timeGetTime() % 1001) / 1000.0f;

/*上面的timeGetTime求余为什么要加1啊,我认为直接要1000就可以了??!*/

D3DXVECTOR3 vecPos = (vecPoints[1] − vecPoints[0]) *Scalar + vecPoints[0];
// Use vecPos.x, vecPos.y, and vecPos.z coordinates for object

248

主题

2674

帖子

2702

积分

金牌会员

Rank: 6Rank: 6

积分
2702
QQ
发表于 2006-1-24 02:20:00 | 显示全部楼层

Re:在计算插值的时候,求余为什么要加1啊

是不是想要0~1000?

3

主题

9

帖子

9

积分

新手上路

Rank: 1

积分
9
 楼主| 发表于 2006-1-24 09:20:00 | 显示全部楼层

Re:在计算插值的时候,求余为什么要加1啊

明白了,谢谢楼上的提醒
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-23 08:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表