Pull to refresh
5
0
Alexey Arkhipenko @Rualark

Developer

Send message

Спасибо за статью. Немного только не понял, разве нужно использовать полноценный intersect в этой задаче? Поскольку точка B лежит в угле CAD (он же PrPoPp), то эта часть intersect кажется всегда будет выполняться: rotate(A,B,C)*rotate(A,B,D)<=0

Тоесть достаточно проверить только то, что точки Po и A лежат по разные стороны от прямой PrPp: rotate(C,D,A)*rotate(C,D,B)<0

As I have said, downsides can be unimportant in your code. Decision has to be made for each particular part of code where you use such an approach.
Hi. Could you please use english language in comments, so that both the post and the discussion are useful to international audience. So, the question is: should we pass shared_ptr by value or create a local copy and dereference it. I added some links with the source of this recommendation so that you can get more detailed information about it.

Passing shared_ptr by value obviously looks more simple and «comfortable» as you say in this simple example, but it also has downsides that I can think of, which may be important or not important in your code:
— you are passing to the function more than it needs (if it just needs a reference) and thus we incapsulate additional logic into that function, making it less general and less eligible for reuse. This function cannot be used for a non-shared_ptr
— you will have to make copy of shared_ptr with every call of this function if you will need to call it multiple times
— you will have to make copy of shared_ptr with every call of other functions in this block if you follow this approach

Also, please note that recommendation is to use auto instead of shared_ptr — you can find out why this is important by following the same link to youtube video.

Information

Rating
Does not participate
Registered
Activity