Files
DParticle/[粒子生成器]DParticle/src/dxp/dpt/shape/Circle.php
2017-12-31 09:57:04 +08:00

44 lines
794 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace dxp\dpt\shape;
/*
圆算法
By:aabbcc872[dxp]
最后一次优化:2017.10.11
参数说明:
r=半径[double|int|float]
data=array(密度)[建议为90因数设为-1弹性计算]
*/
class Circle extends ShapeBase{
public static function getVector3($r=2,$data=array()){
$pos=array();
//密度控制
if(!isset($data[0])){
$k=-1;
}
if($data[0]==0){
return array(0,0,0);
}
if($data[0]==-1){
$ar=round($r,1);
$c=0;
for($a=0;$a<=$ar;$a+=0.1){
$c++;
}
$b=360/($c*4);
if($b>90 || $b<0){
$b=3;
}
for($i=0;$i<=90;$i+=$b){
$x=$r*cos(deg2rad($i));
$z=$r*sin(deg2rad($i));
$pos[]=array($x,0,$z);
$pos[]=array(-$z,0,$x);
$pos[]=array(-$x,0,-$z);
$pos[]=array($z,0,-$x);
}
unset($r,$data,$i,$x,$z);
return $pos;
}
}
?>