Q. How can we find the angle between two points in a 2D space as shown in the figure if the
positions are given
take this care
Point Ax = 2.8
Point Ay = 3.2
Point Bx = 5.2
Point By = 6.2
say you are doing this calculation in python here it goes in python
import math
angle = math.atan2(Bx-Ax, By-Ay)
ie
angleR = math.atan2(5.2-2.8, 6.2-3.2)
0.6747094222355274
since this result is in radians u neet to convert it to degrees using
math.degrees(angle)
38.659808254090095
Fx Programming
Saturday, January 1, 2011
Friday, October 15, 2010
Smoothstep function
We have smooth step function in almost all application here is an example how to write a smoothstep function manualy
smoothstep = x*x – sin(x)
here is a graphical representation for smoothstep graph and python code
Friday, October 8, 2010
How to find Random points inside a given triangle
According to Bary Centric Coordinates it says if a triangle with points A, B, C is on a 2D or 3D dimension then a point inside triangle
N(point inside triangle) = ((t1*A)+(t2*B)+(t3*C))
where t1, t2, t3 is any radom value between 0 and 1 but also a condition exist ie
t1+t2+t3 =1
here is a sample code with a graphical representation code
this can be even used inside other softwares like maya, houdini also like imagine you have to genereate curves between 3 selected points etc...
** Note: To run the sample python code matplotlib graphics library is required.
N(point inside triangle) = ((t1*A)+(t2*B)+(t3*C))
where t1, t2, t3 is any radom value between 0 and 1 but also a condition exist ie
t1+t2+t3 =1
here is a sample code with a graphical representation code
this can be even used inside other softwares like maya, houdini also like imagine you have to genereate curves between 3 selected points etc...
** Note: To run the sample python code matplotlib graphics library is required.
Subscribe to:
Posts (Atom)