首页 > 文档 > modelY()模型Y坐标
2017
08-07

modelY()模型Y坐标

Name

modelY()模型Y坐标

   

Examples

void setup() {

size(500, 500, P3D);

noFill();

}

 

void draw() {

background(0);

 

pushMatrix();

// start at the middle of the screen

translate(width/2, height/2, -200);

// some random rotation to make things interesting

rotateY(1.0); //yrot);

rotateZ(2.0); //zrot);

// rotate in X a little more each frame

rotateX(frameCount / 100.0);

// offset from center

translate(0, 150, 0);

 

// draw a white box outline at (0, 0, 0)

stroke(255);

box(50);

 

// the box was drawn at (0, 0, 0), store that location

float x = modelX(0, 0, 0);

float y = modelY(0, 0, 0);

float z = modelZ(0, 0, 0);

// clear out all the transformations

popMatrix();

 

// draw another box at the same (x, y, z) coordinate as the other

pushMatrix();

translate(x, y, z);

stroke(255, 0, 0);

box(50);

popMatrix();

}

Description

Returns the three-dimensional X, Y, Z position in model space. This returns the X value for a given coordinate based on the current set of transformations (scale, rotate, translate, etc.) The X value can be used to place an object in space relative to the location of the original point once the transformations are no longer in use. 

In the example, the modelX()modelY(), and modelZ() functions record the location of a box in space after being placed using a series of translate and rotate commands. After popMatrix() is called, those transformations no longer apply, but the (x, y, z) coordinate returned by the model functions is used to place another box in the same location.

返回模型空间中的三维 XYZ 位置。这将根据当前的转换集 (缩放、旋转、平移等) 返回给定坐标的 X 值。当转换不再被使用时, X 值可用于将一个对象放置在空间中, 相对于原始点的位置。

 

在本例中, modelX ()modelY () modelZ () 函数在使用一系列平移和旋转命令放置后, 将框的位置记录在空间中。在调用 popMatrix () , 这些转换不再适用, 但由模型函数返回的 (x,yz) 坐标用于在同一位置放置另一个框。

Syntax

modelY(x, y, z)

Parameters

x

float: 3D x-coordinate to be mapped

 

要映射的 3D x 坐标

y

float: 3D y-coordinate to be mapped

 

要映射的 3D y 坐标

z

float: 3D z-coordinate to be mapped

 

要映射的 3D z 坐标

Returns

float

Related

modelY()
modelZ()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。