在3D-netlogo中定义航向俯仰和滚转的问题

时间:2014-11-04 22:23:10

标签: netlogo

我想在建筑物上模拟太阳光线。对于太阳光线的角度,我有正确的仰角和方位角。我正在计算航向和俯仰的相应值。但是前进,俯仰和翻滚似乎相互影响。当标题改变时,音调也会改变。我不知道如何计算我的角度的相应值。 我正在检查netlogo库中的“Turtle and Observer Motion”代码示例,但这没有用。

这是我的代码到目前为止: 角度应每60个刻度改变一次(列表中的位置改变) 列表包含转换的标题和音高值

globals [h  ; heading
  p        ; pitch
   r       ;  roll
   i      ; instead of tick
   data_az    ; a list with the azimuth angles
   data_el    ; a list with the elevation angles
   hour       ; is the position of the angles in the list, stands for the hour
   i_test
   i_round
  ] 
breed [rays ray]
to setup
  ca
  file-open "heading.txt"  
  set data_az file-read
  file-close

  file-open "pitch.txt"   
  set data_el file-read
  file-close
   check-date
    set r 0
  set i 1
  set hour hour - 1 
    set-default-shape rays "line half"
    reset-ticks
end
to go

  tick

   if i = 1440   ; after 24x60 i stop     
  [
    stop
    ]

   set i_test  i / 60              
   set i_round round i_test       



   if i_test = i_round or i = 1   
   [                                
    set hour hour + 1              
       set h item hour data_az
      set p item hour data_el

    ] 



  if h != 0         
       [
         create-sunshine
         run-sunshine
         ]





  set i i + 1

  close

end 
to create-sunshine 

  create-rays 5 [ setxyz random-pxcor max-pycor random-pzcor

      set color yellow
      set heading h
     set pitch p
     set roll r

      set size 2


  ]
end
to run-sunshine
  ask rays [fd 1]
  ask rays  [if pxcor = 0 [die]]  ;rays stop at the edges
  ask rays  [if pxcor = 199 [die]]
 ask rays  [if pycor = 0 [die]]
  ask rays  [if pycor = 49 [die]]
  ask rays  [if pzcor = 0 [die]]
  ask rays  [if pzcor = 199 [die]]
end
to close 
  file-close-all 
end 
to check-date
  if date = "march-equinox" [set hour 0]
  if date = "summer-solstice" [set hour 24]
 if date = "september-equinox" [set hour 48]
  if date = "winter-solstice" [set hour 72]
end

期待您的推荐! 提前致谢 亚娜

2 个答案:

答案 0 :(得分:1)

从我们的讨论中

想法1 让其中一只乌龟面对一个点,它可以为你提供正确的仰角和方位角,并为其余的海龟复制这些值。像

这样的东西
 Ask one-of turtles 
         [
         Facexyz 1000 45663 4663; or something
         Ask other turtles[
                            Set heading [heading] of myself
                             Set pitch [pitch] of myself.   
                              ]

创意2

如果roll设置为0,则俯仰应等于仰角,航向应等于方位角。

答案 1 :(得分:0)

所以它适用于创意1.谢谢!

这是现在的代码:

globals [x
  y
  z
  data_x
data_y
data_z
hour
i
i_test
   i_round
   leader

]

breed [rays ray]

to setup
  ca
  file-open "x.txt" ; three files are loaded with x y and z coordinates respectevely.
  set data_x file-read
  file-close

  file-open "y.txt"
  set data_y file-read
  file-close

  file-open "z.txt"
  set data_z file-read
  file-close

  set hour hour - 1
  set i 1
  set-default-shape rays "line half"

    reset-ticks
end



to go
  tick
  if i = 1440 [
    stop]

  set i_test i / 60
  set i_round round i_test

  if i_test = i_round or i = 1 [
    set hour hour + 1
    set x item hour data_x
    set y item hour data_y
    set z item hour data_z]

  if i_test = i_round or i = 1 [
  if y != 0 [
    create-leader 
    create-follower
  run-sunshine]]

  set i i + 1
  close

end



to create-leader  
    crt 1 [setxyz x y z 
      facexyz 45 1 45
    set leader who
    ]
  end

to create-follower  
  crt 5 [setxyz random-xcor 70 random-zcor
    set heading [heading] of turtle leader
    set pitch [pitch] of turtle leader
    ]
end

to run-sunshine
  ask turtles [fd 1 
    pendown]

end

to close 
  file-close-all 
end