首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谁能给我解释一下。坐标

谁能给我解释一下。坐标
EN

Stack Overflow用户
提问于 2014-06-18 19:41:34
回答 1查看 883关注 0票数 0

谁能解释一下什么是w.r.t.坐标?或者至少带我去一个解释他们是什么的地方?我已经搜索了两天左右,我发现的只是关于它们是如何使用的教程,而不是它们实际上是什么,甚至wrt代表什么。

这些教程假设我已经知道它们是什么,这是很有压力的,因为我从来没有听说过它们。

我在as3工作,试图用像素粒子做一些参数曲面,我知道这些在移动粒子时是很有用的。

这是相关的函数,它们被用作u,v和w,其中p是一个粒子,它也包含没有被修改的xyz值。

代码语言:javascript
复制
function onEnter(evt:Event):void {

dphi = 0.015*Math.cos(getTimer()*0.000132);
dtheta = 0.017*Math.cos(getTimer()*0.000244);

phi = (phi + dphi) % pi2;
theta = (theta + dtheta) % pi2;

cost = Math.cos(theta);
sint = Math.sin(theta);
cosp = Math.cos(phi);
sinp = Math.sin(phi);

//We calculate some of the rotation matrix entries here for increased efficiency:
M11 = cost*sinp;
M12 = sint*sinp;
M31 = -cost*cosp;
M32 = -sint*cosp;

p = firstParticle;

//////// redrawing ////////
displayBitmapData.lock();

//apply filters pre-update
displayBitmapData.colorTransform(displayBitmapData.rect,darken);
displayBitmapData.applyFilter(displayBitmapData, displayBitmapData.rect, origin, blur);

p = firstParticle;
do {

    //Calculate rotated coordinates     
    p.u = M11*p.x + M12*p.y + cosp*p.z;
    p.v = -sint*p.x + cost*p.y;
    p.w = M31*p.x + M32*p.y + sinp*p.z;

    //Calculate viewplane projection coordinates
    m = fLen/(fLen - p.u);
    p.projX = p.v*m + projCenterX;
    p.projY = p.w*m + projCenterY;

    if ((p.projX > displayWidth)||(p.projX<0)||(p.projY<0)||(p.projY>displayHeight)||(p.u>uMax)) {
        p.onScreen = false;
    }
    else {
        p.onScreen = true;
    }

    if (p.onScreen) {

            //we read the color in the position where we will place another particle:
            readColor = displayBitmapData.getPixel(p.projX, p.projY);

            //we take the blue value of this color to represent the current brightness in this position,
            //then we increase this brightness by levelInc.
            level = (readColor & 0xFF)+levelInc;

            //we make sure that 'level' stays smaller than 255:
            level = (level > 255) ? 255 : level;

            /*
            We create light blue pixels quickly with a trick:
            the red component will be zero, the blue component will be 'level', and
            the green component will be 50% of the blue value.  We divide 'level' in
            half using a fast technique: a bit-shift operation of shifting down by one bit
            accomplishes the same thing as dividing by two (for an integer output).
            */
            //dColor = ((level>>1) << 8) | level;

            dColor = (level << 16) | (level << 8) | level;

            displayBitmapData.setPixel(p.projX, p.projY, dColor);               
    }

    p = p.next;

} while (p != null)

displayBitmapData.unlock();

}

这就是我使用http://www.flashandmath.com/flashcs4/light/的例子,我有点理解它们是如何使用的,但我不明白为什么。

提前谢谢。

PD:有点奇怪,竟然连一个标签都没有。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-18 20:36:48

在链接的Particle3D.as类中,它们有:

代码语言:javascript
复制
//coords WRT viewpoint axes
public var u:Number;
public var v:Number;
public var w:Number;

从您发布的代码示例中可以清楚地看到,coords WRT viewpoint axes的意思是coordinates with respect to viewpoint axes,因为代码正是这样做的。

他们正在做的是一个摄像机(或查看)转换,其中粒子的世界坐标(x,y,z)从世界坐标系转换为相机(或视图)坐标系中的坐标(u,v,w)。

(x,y,z)是在world坐标系中的坐标。

(u,v,w)是粒子相机坐标系中的坐标。

例如,世界坐标系的原点可能在(0,0,0),摄像机定位在(5,3,6),查找向量为(1,0,0),向上矢量为(0,1,0)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24293797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档