505{
510
511 if(calcNorm) { *validNorm = false; }
512
513
514
515
516
517
518
519
520
522
523
524
526
527 if ( rho2 < paraRho2 &&
sqr(rho2 - paraRho2 - 0.25 * tol2) > tol2 * paraRho2
529 {
530
531
533 {
534
535
536
537
538
539 intersection = (dz - p.
z()) / v.
z();
541
543 {
544 if(calcNorm)
545 {
547 if(r2 < tolh || ip.
perp2() >
sqr(r2 - tolh))
548 {
551 }
552 *validNorm = true;
553 }
554 return intersection;
555 }
556 }
557 else if(v.z() < 0)
558 {
559
560
561
562
563
564 intersection = (-dz - p.
z()) / v.z();
566
568 {
569 if(calcNorm)
570 {
572 if(r1 < tolh || ip.
perp2() >
sqr(r1 - tolh))
573 {
576 }
577 *validNorm = true;
578 }
579 return intersection;
580 }
581 }
582
583
584
585 if(vRho2 == 0)
586 {
587 intersection = ((rho2 - k2)/k1 - p.
z())/v.z();
588 if(calcNorm)
589 {
593
594 *validNorm = true;
595 }
596 return intersection;
597 }
598 else if( ((
A <= 0) && (B >=
sqr(
A) * (
sqr(vRho2) - 1))) || (
A >= 0))
599 {
600
601
602
603
605 B = (k1 * p.
z() + k2 - rho2)/vRho2;
606 intersection =
B/(-
A + std::sqrt(B +
sqr(
A)));
607 if(calcNorm)
608 {
612 *validNorm = true;
613 }
614 return intersection;
615 }
616 std::ostringstream message;
617 message << "There is no intersection between given line and solid!"
620 << " v = " << v;
621 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
623
624 return kInfinity;
625 }
627 ||
sqr(rho2 - paraRho2 - 0.25 * tol2) < tol2 * paraRho2 )
628 && std::fabs(p.
z()) < dz + tolh)
629 {
630
631
633
634 if(std::fabs(p.
z()) > dz - tolh)
635 {
636
637
638 if( ((v.z() > 0) && (p.
z() > 0)) || ((v.z() < 0) && (p.
z() < 0)) )
639 {
640 if(calcNorm)
641 {
642 *validNorm = true;
645 else
647 }
648 return 0;
649 }
650
651 if(v.z() == 0)
652 {
653
654
655
656
660 intersection = (-pDotV + std::sqrt(
A +
sqr(pDotV))) / vRho2;
661
662 if(calcNorm)
663 {
664 *validNorm = true;
665
668 * intersection, -k1/2).
unit()).unit();
669 }
670 return intersection;
671 }
672 }
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694 if(v.z() > 0)
695 {
696
697
698 intersection = (dz - p.
z()) / v.z();
700
702 {
703 if(calcNorm)
704 {
705 *validNorm = true;
707 }
708 return intersection;
709 }
710 else if(ip.
perp2() <
sqr(r2 + tolh))
711 {
712 if(calcNorm)
713 {
714 *validNorm = true;
718 }
719 return intersection;
720 }
721 }
722 if( v.z() < 0)
723 {
724
725
726 intersection = (-dz - p.
z()) / v.z();
728
730 {
731 if(calcNorm)
732 {
733 *validNorm = true;
735 }
736 return intersection;
737 }
738 else if(ip.
perp2() <
sqr(r1 + tolh))
739 {
740 if(calcNorm)
741 {
742 *validNorm = true;
746 }
747 return intersection;
748 }
749 }
750
751
752
753 if(std::fabs(vRho2) > tol2)
754 {
756 B = (k1 * p.
z() + k2 - rho2);
758 {
760 intersection =
B/(-
A + std::sqrt(B +
sqr(
A)));
761 }
762 else
763 {
764 if(normal.
dot(v) >= 0)
765 {
766 if(calcNorm)
767 {
768 *validNorm = true;
770 }
771 return 0;
772 }
774 }
775 }
776 else
777 {
778 intersection = ((rho2 - k2) / k1 - p.
z()) / v.z();
779 }
780
781 if(calcNorm)
782 {
783 *validNorm = true;
785 + intersection * v.y(), - k1 / 2);
787 }
788 return intersection;
789 }
790 else
791 {
792#ifdef G4SPECSDEBUG
794 {
795 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
797 }
798 else
799 G4Exception(
"G4Paraboloid::DistanceToOut(p,v,...)",
"GeomSolids1002",
800 JustWarning,
"There's an error in this functions code.");
801#endif
802 return kInfinity;
803 }
804 return 0;
805}
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const