# \_\_main\_\_.PVector vs. processing.core.PVector

**URL:** <https://discourse.processing.org/t/main-pvector-vs-processing-core-pvector/22940>\
**Category:** Processing.py\
**Created:** [July 30, 2020, 11:15pm UTC](https://discourse.processing.org/t/main-pvector-vs-processing-core-pvector/22940 "2020-07-30T23:15:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [July 30, 2020, 11:15pm UTC](https://discourse.processing.org/t/main-pvector-vs-processing-core-pvector/22940/1 "2020-07-30T23:15:21Z")

</div>

I was playing with OpenCV and sometimes I use a method that returns a PVector like: `opencv.getAverageFlow()`, but it is a `<type 'processing.core.PVector'>` and not `<class ' __main__.PVector'>` as one created by the sketch.

![sketch_2020_07_30d](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/264b30d3724ec90c05e16225203e4bbd845c3cc6.gif)

I bothers me a bit because I don’t seem to be able to use the nice Python infix operators I love with them, v1 += v2 instead of v1.add(v2) etc.

Is there anything I can do about this (short of converting them with `v = PVector(v.x, v.y, v.z)`)?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 30, 2020, 11:22pm UTC](https://discourse.processing.org/t/main-pvector-vs-processing-core-pvector/22940/2 "2020-07-30T23:22:53Z")

</div>

You may try out this workaround: `PVector().set(opencv.getAverageFlow())` 🐍

Alternatively this shorter version might work too: `PVector().set(opencv.averageFlow)` 😉

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [July 30, 2020, 11:40pm UTC](https://discourse.processing.org/t/main-pvector-vs-processing-core-pvector/22940/3 "2020-07-30T23:40:59Z")

</div>

The first syntax works perfectly, thank you!  
The second one complains, similar, I think, as I when I tried `main_pv = PVector(core_pv)`. Cheers!

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [July 31, 2020, 7:43am UTC](https://discourse.processing.org/t/main-pvector-vs-processing-core-pvector/22940/4 "2020-07-31T07:43:51Z")

</div>

I’m not too familiar with jython but I assume it should be possible to do something like I have with JRuby to create a python class in java as I have with my ruby-processing implementations. I created [Vec2D](http://ruby-processing.github.io/JRubyArt/classes/vec2d/) and [Vec3D](http://ruby-processing.github.io/JRubyArt/classes/vec3d/) classes to make more ruby friendly classes, to make great benefit all round when programming in ruby. I added missing features such as being able to duck-type, convert Vectors to vertex etc. See java code for [Vec3D class](https://github.com/ruby-processing/JRubyArt/blob/master/src/main/java/monkstone/vecmath/vec3/Vec3.java).

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [July 31, 2020, 3:11pm UTC](https://discourse.processing.org/t/main-pvector-vs-processing-core-pvector/22940/5 "2020-07-31T15:11:50Z")

</div>

Very nice!

The PVector implemented by JDF in Python mode is very pythonic already, this is the first time I notice there still is such thing as a “Java PVector” (being returned by the imported lib) that needed converting 🙂
