Vector functions question

for this example, you’re given the radius AB (or AD) and CB…

things to find are:
length of CD and the central angle.

normally, i’d use

angleCAD = acos((AB-CB)/AD)

then CD could be = sin(CAD)•AD

what i’m curious about though is how to get the lengths/points/angles without explicitly using trig and only using the vector functions in python.

and not really looking for ideas about just draw the lines/arc then find the intersecting points etc… i mean, i’m interested if there’s a convincing argument for it but i’m thinking trig is faster/easier… mainly just wondering if using vectors is even easier/faster… (basically… looking for point D without finding the angle first if possible etc)


Vector mathematics is great for lines and triangles, not so great for circles. Also, the trig approach sort of works better if you have an abstract problem like this one. You don’t really care where the geometry is or how it’s oriented, all you have are some key variables. The strength of vector mathematics on the other hand is exactly that it doesn’t care about position and orientation, but it does require the variables to be somewhere in space. If you want to redo the above using vector maths, you’ll first have to create all the vectors/points you need from the known values and assumed orientations, so I doubt it’s going to be less code or faster.

Here’s how I’d do it using vector maths. Note that the usual way to compute the angle between two vectors is to use the dot product, however that returns the cosine of the angle. So you still need an acos to get the actual angle. (12.2 KB)

hey David,

i think i might not of given the best example because it’s pretty obvious trig is the best way to solve in that instance… there are a lot of other thing which need built off this initial input in which vectors will probably be the way to go.

i guess i should of been more exact in my question because i can figure out what all the vector functions are doing except one… VectorDotProduct

i’ve never heard of a dot product before and none of the examples i’ve seen, nor any of the experiments i’ve tried have made me feel "ok, this is exactly what that function is doing’

so, do you know of any simple situations which make it real clear what it’s doing?

on a side note… just realized those grasshopper components look fairly yosemite like ; )

There are two multiplication functions that work on vectors. The dot product takes two vectors and returns a number. The number is the length of the projection of one vector onto the other. The cross product returns a third vector which is perpendicular to both inputs. Neither the dot-product, nor the cross product are commutative (side note, the dot product is commutative if both vectors have the same length I think).

The dot product seems to have little relevance at first, but it pops up in a lot of algorithms. It’s also very quick to calculate, which is why programmers like it so much.

Hi David. ( Happy new year ! )
AFAIK the dot product is the product of the lengths of the two vectors times the cosine of the angle between them.
That gives the length of the projection of the first vector onto the second only when the second vector is a unit vector.
It also is commutative.

hey emilio-- do you have a visual example? like- under what circumstance would you use VectorDotProduct?

i learn better from looking at the pictures instead of reading the words :smile:

Hi Jeff ( Happy new year to you too ! :smile: )

As David said, the dot product is often used to project a vector onto a direction.
Here we have an unknown vector AB and an arbitrary coordinate system.
To find the components of AB for our coordinate system we can use the dot product.
For example the distance ZA->ZB, that is the projection of the vector AB onto our system’s Z axis, is given by the dot product of AB and our Z axis unit vector.
Obviously the same can be done for the X and Y axes of the coord system and for whatever direction we may have to check.

Does that make sense ?

haha. sort of… i’ll have another look tomorrow.

Here is a good read:

Oops… thanks for setting me straight.

perfect! thank you.

(you had me at the preface-- The material is directed towards designers who have little or no background in mathematics beyond high school. :smiley: )