Python Vector Math



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/10/2010 at 18:30, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:      Mac OSX  ; 
    Language(s) :       PYTHON  ;

    ---------
    Hi Sebastian,  i think I may have stumbled on a bug bug it could be I don't know what i am doing.

    Take this example
    vec = c4d.Vector (0,0,10)
    vec - vec * vec
    print vec 
    I would expect the result to be (0,0,100)  but instead I get (100,100,100)
    same result happens if I use vec.__mul__(vec)

    If I do division:
    vec = vec /2
    I get (0,0,5), which is what I would expect.

    regards,
    jonah



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/10/2010 at 07:21, xxxxxxxx wrote:

    Hi jonahtobias,

    the __mul__ (* ) operator for the Vector class returns the dot product.
    It should return a float value and no Vector. Please use
    Vector(...).Dot(Vector(...))  for the dot product calculation which works fine.

    Cheers, Sebastian



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/10/2010 at 08:21, xxxxxxxx wrote:

    Thank Sebastian,

    So if I wanted to multiply 2 Vectors i.e.
    Vector(10,2,2) * Vector(10,2,2) so the result is == (100,4,4)
    how would I do this?
    right now python gives (108,108,108)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/10/2010 at 08:26, xxxxxxxx wrote:

    Use the __xor__ operator for this: Vector(1,2,3) ^ Vector(4, 5, 6)

    Multiplies two vectors together componentwise



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/10/2010 at 08:29, xxxxxxxx wrote:

    Terrific!  Thank you.


Log in to reply