You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LineSmoother.cs 3.9KB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ÿþu�s�i�n�g� �U�n�i�t�y�E�n�g�i�n�e�;�
  2. �u�s�i�n�g� �S�y�s�t�e�m�.�C�o�l�l�e�c�t�i�o�n�s�;�
  3. �u�s�i�n�g� �S�y�s�t�e�m�.�C�o�l�l�e�c�t�i�o�n�s�.�G�e�n�e�r�i�c�;�
  4. �
  5. �p�u�b�l�i�c� �c�l�a�s�s� �L�i�n�e�S�m�o�o�t�h�e�r� �:� �M�o�n�o�B�e�h�a�v�i�o�u�r� �
  6. �{�
  7. � �p�u�b�l�i�c� �s�t�a�t�i�c� �V�e�c�t�o�r�3�[�]� �S�m�o�o�t�h�L�i�n�e�(� �V�e�c�t�o�r�3�[�]� �i�n�p�u�t�P�o�i�n�t�s�,� �f�l�o�a�t� �s�e�g�m�e�n�t�S�i�z�e� �)�
  8. � �{�
  9. � � �/�/�c�r�e�a�t�e� �c�u�r�v�e�s�
  10. � � �A�n�i�m�a�t�i�o�n�C�u�r�v�e� �c�u�r�v�e�X� �=� �n�e�w� �A�n�i�m�a�t�i�o�n�C�u�r�v�e�(�)�;�
  11. � � �A�n�i�m�a�t�i�o�n�C�u�r�v�e� �c�u�r�v�e�Y� �=� �n�e�w� �A�n�i�m�a�t�i�o�n�C�u�r�v�e�(�)�;�
  12. � � �A�n�i�m�a�t�i�o�n�C�u�r�v�e� �c�u�r�v�e�Z� �=� �n�e�w� �A�n�i�m�a�t�i�o�n�C�u�r�v�e�(�)�;�
  13. �
  14. � � �/�/�c�r�e�a�t�e� �k�e�y�f�r�a�m�e� �s�e�t�s�
  15. � � �K�e�y�f�r�a�m�e�[�]� �k�e�y�s�X� �=� �n�e�w� �K�e�y�f�r�a�m�e�[�i�n�p�u�t�P�o�i�n�t�s�.�L�e�n�g�t�h�]�;�
  16. � � �K�e�y�f�r�a�m�e�[�]� �k�e�y�s�Y� �=� �n�e�w� �K�e�y�f�r�a�m�e�[�i�n�p�u�t�P�o�i�n�t�s�.�L�e�n�g�t�h�]�;�
  17. � � �K�e�y�f�r�a�m�e�[�]� �k�e�y�s�Z� �=� �n�e�w� �K�e�y�f�r�a�m�e�[�i�n�p�u�t�P�o�i�n�t�s�.�L�e�n�g�t�h�]�;�
  18. �
  19. � � �/�/�s�e�t� �k�e�y�f�r�a�m�e�s�
  20. � � �f�o�r�(� �i�n�t� �i� �=� �0�;� �i� �<� �i�n�p�u�t�P�o�i�n�t�s�.�L�e�n�g�t�h�;� �i�+�+� �)�
  21. � � �{�
  22. � � � �k�e�y�s�X�[�i�]� �=� �n�e�w� �K�e�y�f�r�a�m�e�(� �i�,� �i�n�p�u�t�P�o�i�n�t�s�[�i�]�.�x� �)�;�
  23. � � � �k�e�y�s�Y�[�i�]� �=� �n�e�w� �K�e�y�f�r�a�m�e�(� �i�,� �i�n�p�u�t�P�o�i�n�t�s�[�i�]�.�y� �)�;�
  24. � � � �k�e�y�s�Z�[�i�]� �=� �n�e�w� �K�e�y�f�r�a�m�e�(� �i�,� �i�n�p�u�t�P�o�i�n�t�s�[�i�]�.�z� �)�;�
  25. � � �}�
  26. �
  27. � � �/�/�a�p�p�l�y� �k�e�y�f�r�a�m�e�s� �t�o� �c�u�r�v�e�s�
  28. � � �c�u�r�v�e�X�.�k�e�y�s� �=� �k�e�y�s�X�;�
  29. � � �c�u�r�v�e�Y�.�k�e�y�s� �=� �k�e�y�s�Y�;�
  30. � � �c�u�r�v�e�Z�.�k�e�y�s� �=� �k�e�y�s�Z�;�
  31. �
  32. � � �/�/�s�m�o�o�t�h� �c�u�r�v�e� �t�a�n�g�e�n�t�s�
  33. � � �f�o�r�(� �i�n�t� �i� �=� �0�;� �i� �<� �i�n�p�u�t�P�o�i�n�t�s�.�L�e�n�g�t�h�;� �i�+�+� �)�
  34. � � �{�
  35. � � � �c�u�r�v�e�X�.�S�m�o�o�t�h�T�a�n�g�e�n�t�s�(� �i�,� �0� �)�;�
  36. � � � �c�u�r�v�e�Y�.�S�m�o�o�t�h�T�a�n�g�e�n�t�s�(� �i�,� �0� �)�;�
  37. � � � �c�u�r�v�e�Z�.�S�m�o�o�t�h�T�a�n�g�e�n�t�s�(� �i�,� �0� �)�;�
  38. � � �}�
  39. �
  40. � � �/�/�l�i�s�t� �t�o� �w�r�i�t�e� �s�m�o�o�t�h�e�d� �v�a�l�u�e�s� �t�o�
  41. � � �L�i�s�t�<�V�e�c�t�o�r�3�>� �l�i�n�e�S�e�g�m�e�n�t�s� �=� �n�e�w� �L�i�s�t�<�V�e�c�t�o�r�3�>�(�)�;�
  42. �
  43. � � �/�/�f�i�n�d� �s�e�g�m�e�n�t�s� �i�n� �e�a�c�h� �s�e�c�t�i�o�n�
  44. � � �f�o�r�(� �i�n�t� �i� �=� �0�;� �i� �<� �i�n�p�u�t�P�o�i�n�t�s�.�L�e�n�g�t�h�;� �i�+�+� �)�
  45. � � �{�
  46. � � � �/�/�a�d�d� �f�i�r�s�t� �p�o�i�n�t�
  47. � � � �l�i�n�e�S�e�g�m�e�n�t�s�.�A�d�d�(� �i�n�p�u�t�P�o�i�n�t�s�[�i�]� �)�;�
  48. �
  49. � � � �/�/�m�a�k�e� �s�u�r�e� �w�i�t�h�i�n� �r�a�n�g�e� �o�f� �a�r�r�a�y�
  50. � � � �i�f�(� �i�+�1� �<� �i�n�p�u�t�P�o�i�n�t�s�.�L�e�n�g�t�h� �)�
  51. � � � �{�
  52. � � � � �/�/�f�i�n�d� �d�i�s�t�a�n�c�e� �t�o� �n�e�x�t� �p�o�i�n�t�
  53. � � � � �f�l�o�a�t� �d�i�s�t�a�n�c�e�T�o�N�e�x�t� �=� �V�e�c�t�o�r�3�.�D�i�s�t�a�n�c�e�(�i�n�p�u�t�P�o�i�n�t�s�[�i�]�,� �i�n�p�u�t�P�o�i�n�t�s�[�i�+�1�]�)�;�
  54. �
  55. � � � � �/�/�n�u�m�b�e�r� �o�f� �s�e�g�m�e�n�t�s�
  56. � � � � �i�n�t� �s�e�g�m�e�n�t�s� �=� �(�i�n�t�)�(�d�i�s�t�a�n�c�e�T�o�N�e�x�t� �/� �s�e�g�m�e�n�t�S�i�z�e�)�;�
  57. �
  58. � � � � �/�/�a�d�d� �s�e�g�m�e�n�t�s�
  59. � � � � �f�o�r�(� �i�n�t� �s� �=� �1�;� �s� �<� �s�e�g�m�e�n�t�s�;� �s�+�+� �)�
  60. � � � � �{�
  61. � � � � � �/�/�i�n�t�e�r�p�o�l�a�t�e�d� �t�i�m�e� �o�n� �c�u�r�v�e�
  62. � � � � � �f�l�o�a�t� �t�i�m�e� �=� �(�(�f�l�o�a�t�)�s�/�(�f�l�o�a�t�)�s�e�g�m�e�n�t�s�)� �+� �(�f�l�o�a�t�)�i�;�
  63. �
  64. � � � � � �/�/�s�a�m�p�l�e� �c�u�r�v�e�s� �t�o� �f�i�n�d� �s�m�o�o�t�h�e�d� �p�o�s�i�t�i�o�n�
  65. � � � � � �V�e�c�t�o�r�3� �n�e�w�S�e�g�m�e�n�t� �=� �n�e�w� �V�e�c�t�o�r�3�(� �c�u�r�v�e�X�.�E�v�a�l�u�a�t�e�(�t�i�m�e�)�,� �c�u�r�v�e�Y�.�E�v�a�l�u�a�t�e�(�t�i�m�e�)�,� �c�u�r�v�e�Z�.�E�v�a�l�u�a�t�e�(�t�i�m�e�)� �)�;�
  66. �
  67. � � � � � �/�/�a�d�d� �t�o� �l�i�s�t�
  68. � � � � � �l�i�n�e�S�e�g�m�e�n�t�s�.�A�d�d�(� �n�e�w�S�e�g�m�e�n�t� �)�;�
  69. � � � � �}�
  70. � � � �}�
  71. � � �}�
  72. �
  73. � � �r�e�t�u�r�n� �l�i�n�e�S�e�g�m�e�n�t�s�.�T�o�A�r�r�a�y�(�)�;�
  74. � �}�
  75. �
  76. �}�
  77. �