Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
POV-RAY代码转换为Python';蒸汽_Python_Povray - Fatal编程技术网

POV-RAY代码转换为Python';蒸汽

POV-RAY代码转换为Python';蒸汽,python,povray,Python,Povray,在这里,我试图将一些POV-Ray代码转换为Python。我在用蒸汽舱。特别是,部分scale*1.75和颜料{color rgb*1.1}非常容易混淆。无法理解如何将*1.75和*1.1添加到Python代码中 纯POV射线代码: box { <-0.04,-0.04,0>,< 1.03, 1.04, 0.01> // 1st layer: White texture{ pigment{ color rgb<1,1,

在这里,我试图将一些POV-Ray代码转换为Python。我在用蒸汽舱。特别是,部分
scale*1.75
颜料{color rgb*1.1}
非常容易混淆。无法理解如何将
*1.75
*1.1
添加到Python代码中

纯POV射线代码:

box { <-0.04,-0.04,0>,< 1.03, 1.04, 0.01>   
      // 1st layer: White
      texture{ 
        pigment{ color rgb<1,1,1>*1.1 } 
        finish{ phong 1}
      } // ------------------------------ 
      // 2nd layer: image_map
      texture{
        pigment{
          image_map{ jpeg "Image_gamma_0.jpg"  
          // maps an image on the xy plane from <0,0,0> to <1,1,0> (aspect ratio 1:1)
          // accepted types: gif, tga, iff, ppm, pgm, png, jpeg, tiff, sys
          map_type 0 // 0=planar, 1=spherical, 2=cylindrical, 5=torus
          interpolate 2 // 0=none, 1=linear, 2=bilinear, 4=normalized distance
          once //
         } // end of image_map
       } //  end of pigment
     } // end of texture

     scale <4/3,1,1>*1.75
     rotate<  0, 0,0>
     translate<-1.5,0.1,-2>
} // end of box //

您可以使用
numpy
进行向量操作:
python列表[]对应于
POV光线
vector
numpy
数组支持所需的标量乘法(*x)

  • 从列表中创建一个
    numpy
    数组
  • 乘法数组
  • 将数组转换为列表
  • 像这样:

    import numpy as np
    print(list(np.array([1,2,3])*2.5)) 
    
    结果:[2.5,5.0,7.5]


    “量表”[4/3,1,1]]中的i为[i*1.75]列表理解。Vapory似乎没有一个向量类可以使这样的事情变得更容易。实际上,在Python中有一个真正的向量类型会很好。
    import numpy as np
    print(list(np.array([1,2,3])*2.5))