使用 CSS 或 Canvas 的 Web 3D 散点图 (XYZ / RGB)

发布于 2024-12-27 15:58:55 字数 1406 浏览 1 评论 0原文

好吧,我正在尝试绘制 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁拥 2025-01-03 15:58:55

您可以在此处查看演示: http://jsfiddle.net/MadLittleMods/yhCpf/

添加对于每种颜色,点遵循以下准则:

Red: 251 - {Your Red}
Green: 251 - {Your Green
Blue: -124 + {Your Blue}

例如,如果您有颜色 255、85、89,即#FF554F。
你的观点是:

<div class="point" style="-webkit-transform: translate3d(-4px, 166px, -35px); -moz-transform: translate3d(0px, 170px, -39px); -o-transform: translate3d(0px, 170px, -39px); -ms-transform: translate3d(0px, 170px, -39px); transform: translate3d(0px, 170px, -39px);">
    <div class="face one"></div>
    <div class="face two"></div>
    <div class="face three"></div>
    <div class="face four"></div>
    <div class="face five"></div>
    <div class="face six"></div>
</div>

你必须进行加法和减法的原因是因为平面上的原点不在 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:

Red: 251 - {Your Red}
Green: 251 - {Your Green
Blue: -124 + {Your Blue}

For example if you had the color 255, 85, 89 which is #FF554F.
Your point would be:

<div class="point" style="-webkit-transform: translate3d(-4px, 166px, -35px); -moz-transform: translate3d(0px, 170px, -39px); -o-transform: translate3d(0px, 170px, -39px); -ms-transform: translate3d(0px, 170px, -39px); transform: translate3d(0px, 170px, -39px);">
    <div class="face one"></div>
    <div class="face two"></div>
    <div class="face three"></div>
    <div class="face four"></div>
    <div class="face five"></div>
    <div class="face six"></div>
</div>

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文