Hey i kinda need help vectorizing the line below. Mod_normal is a scalar while P1, P2, P3, Prime are points in [xyz] format.
Show older comments
V1 = P2 - prime; V2 = P3 - prime;
alpha = norm(cross_product((V1), (V2)))/ ( Mod_normal);
V1 = P3 - prime; V2 = P1 - prime;
beta = norm(cross_product((V1), (V2)))/ ( Mod_normal);
V1 = P1 - prime; V2 = P2 - prime;
alpha2 = norm(cross_product((V1), (V2)))/ ( Mod_normal);
gamma = 1 - alpha - beta;
gamma2 = 1 - alpha2 - alpha;
gamma3 = 1 - beta - alpha2;
checklist = [alpha, beta,alpha2, gamma2,gamma3, gamma];
4 Comments
Muhamad Amirulfaris Abdullah
on 29 Jul 2019
Maadhav Akula
on 31 Jul 2019
What do you mean by "vectorizing the line below"?
Muhamad Amirulfaris Abdullah
on 31 Jul 2019
Muhamad Amirulfaris Abdullah
on 31 Jul 2019
Answers (1)
Maadhav Akula
on 6 Aug 2019
0 votes
I think the code which you have provided runs pretty fast and only changes in your code would be to use the in-built functions such as cross, dot, norm to compute the cross-product, dot-product and magnitude of vectors respectively.
Hope this helps!
Categories
Find more on Particle & Nuclear Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!