GLAMERDOC++
Gravitational Lensing Code Library
Loading...
Searching...
No Matches
shear.h
1//
2// shear.h
3// GLAMER
4//
5// Created by Robert Benton Metcalf on 24/06/2020.
6//
7// These data structures and functions for storing and
8// minupulating shear and correlations between shears
9// on the sphere and flat-sky
10
11#ifndef shear_h
12#define shear_h
13
14#include "geometry.h"
15
17template <typename T>
19{
20 Point_2d shear;
21 T kappa;
22};
23
25template <typename T>
26Point_2d tangent_cross_shear(
28 ,const Polar<T> &p
29 ){
30 //double d = xo.angular_separation(p);
31 //double cd = cos(d);
32 //double sd = sin(d);
33
34 Point_3d<T> v1 = xo.TOcartisian() /( (xo.r <= 0) ? 1 : xo.r );
35 Point_3d<T> v2 = p.TOcartisian() /( (p.r <= 0) ? 1 : p.r );
36 double cd = v1*v2;
37
38 // tangent vectors to the great circle at the two points
39 Point_3d<T> t2 = (v2 * cd - v1);
40 //Point_3d<T> t2 = ( v2 - v1*cd );
41 t2.unitize();
42
43 // unit vector in theta direction
44 //Point_3d<T> v_theta_2 = p.theta_hat();
45 Point_3d<T> v_theta_2 = p.phi_hat();
46
47 T ct2 = t2*v_theta_2;
48 T st2 = (t2^v2)*v_theta_2;
49
50 double c2theta = ct2*ct2-st2*st2;
51 double s2theta = 2*st2*ct2;
52
53 Point_2d g2;
54
55 g2[0] = c2theta * p.shear[0] + s2theta * p.shear[1];
56 g2[1] = c2theta * p.shear[1] - s2theta * p.shear[0];
57
58 return g2;
59}
60
62Point_2d tangent_cross_shear(
63 const Point_2d &xo
64 ,const Point_2d &x
65 ,const Point_2d &gamma
66 ){
67
68 Point_2d t = (x-xo);
69 t.unitize();
70
71 double c2theta = t[0]*t[0]-t[1]*t[1];
72 double s2theta = 2*t[0]*t[1];
73
74 Point_2d g2;
75
76 g2[0] = c2theta * gamma[0] - s2theta * gamma[1];
77 g2[1] = c2theta * gamma[1] + s2theta * gamma[0];
78
79 return g2;
80}
81
83template <typename T>
84Point_3d<double> correlate(Polar<T> &p1,Polar<T> &p2){
85
86 Point_2d g1,g2;
87
88 g1 = tangent_cross_shear(p2, p1);
89 g2 = tangent_cross_shear(p1, p2);
90
91 return Point_3d<double>(g1[0]*g2[0],g1[1]*g2[1],g1[0]*g2[1]);
92}
93
95Point_3d<double> correlate(Point_2d &x1,Point_2d &g1,Point_2d &x2,Point_2d &g2){
96
97 Point_2d gt1,gt2;
98
99 gt1 = tangent_cross_shear(x1,x2,g2);
100 gt2 = tangent_cross_shear(x2,x1,g1);
101
102 return Point_3d<double>(gt1[0]*gt2[0],gt1[1]*gt2[1],gt1[0]*gt2[1]);
103}
104
105
106#endif /* shear_h */
represents a point in spherical coordinates, theta = 0 is equator
Definition geometry.h:30
void TOcartisian(T x[]) const
output Cartesian coordinates of the point
Definition geometry.h:387
Class for representing points or vectors in 2 dimensions. Not that the dereferencing operator is over...
Definition point.h:48
void unitize()
rescale to make a unit length vector
Definition point.h:162
Class for representing points or vectors in 3 dimensions. Not that the dereferencing operator is over...
Definition point.h:883
void unitize()
rescale to make a unit length vector
Definition point.h:998
this data class represents a postion inspherical coordinates and a polarization relative to the sphir...
Definition shear.h:19