Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

vector question

papawopapawo Member, Developers Posts: 206 PRO

Comments

  • mahirmahir Member, Developers Posts: 1,307 ✭✭✭✭✭
    Vectors can indicate several things - 3D direction, 3D position, 2D position, location on a surface, and probably more that I don't recall. Some of these don't require units; some do. Specifically, direction doesn't need units, but position does. If you're trying to sketch a rectangle, you are feeding the skRectangle function the position of two points. If units are not included, that (1,1) could be (1,1)*inch or (1,1)*meter. So instead of trying to assume a unit, which would probably lead to errors along the way, the function was written to require explicit units. I hope I explained that well enough :smile:
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,211
    The reason is that 1 is a number, while 1 * inch is a length. The locations of rectangle corners are lengths (distances from plane's origin), not numbers, so skRectangle doesn't work without the *inch. The reason we did it this way (as opposed to treating everything as a number) is to catch common errors earlier in the design process (so, e.g., adding 2 * inch + 3 * degree will lead to an error, rather than an unintended result that could slip into manufacturing) by forcing the programmer/engineer to think about units explicitly.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    When referring to a position on a sketch, you need to specify a distance along the X-and Y-axes of the sketch. These distances need to have length units, and can be created in many ways — vector(1, 0) * inch means something different form vector(1, 0) * meter, which means something different from vector(1, 0) * definition.radius, but all of these represent a certain distance along the X-axis, and zero distance along the Y-axis. 

    Under the hood, multiplying vector(1, 0) (a Vector) by inch (a ValueWithUnits) will multiply each component of the vector by the value, resulting in a vector that specifies two distances along the X-and Y-axes, which is what the argument for skRectangle expects.

  • papawopapawo Member, Developers Posts: 206 PRO
    edited October 2016
    Thank you ! Ilya , kevin & Mahir . Now its all clear! :)

Sign In or Register to comment.