MATLAB: Vectorized Distance Calculation to an Array of Opponents
Автор: DoctorBear
Загружено: 2023-11-24
Просмотров: 186
I demonstrate vectorized calculations of distances between a point of interest and an array of other points. This could be used in calculating the distance between a player’s avatar and obstacles or opponents in a game.
MATLAB has some useful functions. We can avoid a (slow) FOR loop by using vectorized calculations. We simply perform array operations and apply functions to the entire array. Here, we make use of vecnorm().
In the advanced techniques part of the video, I use conditional (logical) subscripting. For more on conditional subscripting, see these videos:
(1) • Logical Subscripting in MATLAB
(2) • 03 Logical Subscripting in MATLAB with Exa...
For more on plotting in MATLAB, see here:
(1) • Creating Publication-quality Plots in MATLAB
(2) • MATLAB - Annotated plots
0:00 Start
0:53 Generate location of avatar
1:33 Verification - plot position of avatar
2:08 Generate locations of opponents
2:43 Verification - plot opponents
3:13 Calculate distances
6:21 Further analysis based on distances (advanced techniques)
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: