使用 CSS 或 Canvas 的 Web 3D 散点图 (XYZ / RGB)
好吧,我正在尝试绘制 RGB 值的图表,以便我可以轻松地知道应该将什么作为 Kmean 值定理的 K 值。
但我想弄清楚的是我应该如何绘制我的 3 维数据。现在我正在尝试使用 css3 和 -webkit-transform:translate3d(x, y, z);财产。但我很难想象每次旋转和东西应该是什么。
echo '
<div style="width: 500px; height: 500px; background: #ffffff; -webkit-transform: perspective(800); -webkit-transform-style: preserve-3d;">
<div style="-webkit-transform: rotateZ(0deg); -webkit-transform-style: preserve-3d; position: relative;">
<div style="-webkit-transform: rotateY(-45deg); -webkit-transform-style: preserve-3d; position: relative;">
<div style="-webkit-transform: rotateX(-15deg); -webkit-transform-style: preserve-3d; position: relative;">
';
foreach($Kmean_array['clusters'] as $key_cluster => $cluster)
{
foreach($cluster['points'] as $key_point => $point)
{
echo '
<div style="position: absolute; opacity: .2; width: 4px; height: 4px; background: #', $Kmean_array['chosen_centroid']['hex'] ,'; -webkit-transform: translate3d(', $point['rgb']['r'] ,'px, ', $point['rgb']['g'] ,'px, ',$point['rgb']['b'] ,'px);"></div>
';
}
}
echo '
</div>
</div>
</div>
</div>
';
我完全准备使用某人已经用画布等制作的系统。我只见过用java或flash绘制的图。
Well, I am trying to graph RGB values so that I can easily know what to put as the value of K for the Kmean value theorem.
But what I am trying to figure out is how I should graph my 3 dimensional data. Right now I am trying to use css3 and the -webkit-transform: translate3d(x, y, z); property. But I am having trouble visualizing what each rotation and stuff should be.
echo '
<div style="width: 500px; height: 500px; background: #ffffff; -webkit-transform: perspective(800); -webkit-transform-style: preserve-3d;">
<div style="-webkit-transform: rotateZ(0deg); -webkit-transform-style: preserve-3d; position: relative;">
<div style="-webkit-transform: rotateY(-45deg); -webkit-transform-style: preserve-3d; position: relative;">
<div style="-webkit-transform: rotateX(-15deg); -webkit-transform-style: preserve-3d; position: relative;">
';
foreach($Kmean_array['clusters'] as $key_cluster => $cluster)
{
foreach($cluster['points'] as $key_point => $point)
{
echo '
<div style="position: absolute; opacity: .2; width: 4px; height: 4px; background: #', $Kmean_array['chosen_centroid']['hex'] ,'; -webkit-transform: translate3d(', $point['rgb']['r'] ,'px, ', $point['rgb']['g'] ,'px, ',$point['rgb']['b'] ,'px);"></div>
';
}
}
echo '
</div>
</div>
</div>
</div>
';
I am totally up to using a system that someone has already made with canvas, etc. I have only seen plots with java or flash.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在此处查看演示: http://jsfiddle.net/MadLittleMods/yhCpf/
添加对于每种颜色,点遵循以下准则:
例如,如果您有颜色 255、85、89,即#FF554F。
你的观点是:
你必须进行加法和减法的原因是因为平面上的原点不在 0, 0, 0 而是在 251, 251, -124
更新(2013-11-9):
这里是我制作的 (0, 0, 0) 很棒的 3D 轴。包括每个轴上指向正方向的 3D 箭头。
演示
另请查看我制作的这个网络应用程序,它显示了定义了一些方程的 3D 实体(非动态)带有一些旋转和缩放控件: http://apps.visualpulse.net/calculus-solid/
You can view a demo here: http://jsfiddle.net/MadLittleMods/yhCpf/
To add points follow the guidelines below for each color:
For example if you had the color 255, 85, 89 which is #FF554F.
Your point would be:
The reason you have to do the adding and subtracting is because the origin on the plane is not at 0, 0, 0 instead it is at 251, 251, -124
Update (2013-11-9):
Here is (0, 0, 0) awesome 3D axis I made. Includes 3D arrows pointing in positive directions on each axis.
Demo
Also check out this web app I made that shows a 3D solid defined some equations (not dynamic) with some rotation and zoom controls: http://apps.visualpulse.net/calculus-solid/