Android Dynamically changing circle size only half the circle updates correctly
Date : March 29 2020, 07:55 AM
Hope that helps So I've given the user controls to use a seekbar to change the radius of a circle overlay object in a MapView. , So I added this to the method which draws the circle overlay: mController.animateTo(mLocationOverlay.getMyLocation());
|
Matplotlib half black and half white circle
Date : March 29 2020, 07:55 AM
I wish this helpful for you The easiest way is to use two Wedges. (This doesn't automatically rescale the axes, but that's easy to add, if you'd like.) As a quick example: import matplotlib.pyplot as plt
from matplotlib.patches import Wedge
def main():
fig, ax = plt.subplots()
dual_half_circle((0.5, 0.5), radius=0.3, angle=90, ax=ax)
ax.axis('equal')
plt.show()
def dual_half_circle(center, radius, angle=0, ax=None, colors=('w','k'),
**kwargs):
"""
Add two half circles to the axes *ax* (or the current axes) with the
specified facecolors *colors* rotated at *angle* (in degrees).
"""
if ax is None:
ax = plt.gca()
theta1, theta2 = angle, angle + 180
w1 = Wedge(center, radius, theta1, theta2, fc=colors[0], **kwargs)
w2 = Wedge(center, radius, theta2, theta1, fc=colors[1], **kwargs)
for wedge in [w1, w2]:
ax.add_artist(wedge)
return [w1, w2]
main()
import matplotlib.pyplot as plt
from matplotlib.patches import Wedge
def main():
fig, ax = plt.subplots()
dual_half_circle(radius=0.1, angle=90, ax=ax)
ax.axis('equal')
plt.show()
def dual_half_circle(radius, angle=0, ax=None, colors=('w','k'), **kwargs):
"""
Add two half circles to the axes *ax* (or the current axes) at the lower
left corner of the axes with the specified facecolors *colors* rotated at
*angle* (in degrees).
"""
if ax is None:
ax = plt.gca()
kwargs.update(transform=ax.transAxes, clip_on=False)
center = (0, 0)
theta1, theta2 = angle, angle + 180
w1 = Wedge(center, radius, theta1, theta2, fc=colors[0], **kwargs)
w2 = Wedge(center, radius, theta2, theta1, fc=colors[1], **kwargs)
for wedge in [w1, w2]:
ax.add_artist(wedge)
return [w1, w2]
main()
|
Find near by places of specific angle - consider only half circle of front not the back in round circle query
Tag : mysql , By : Alex S
Date : March 29 2020, 07:55 AM
will help you You can plot points inside a segment using Haversine/Spherical Law of Cosines for the radius. Then use pointInPolygon() to find only those within segment. You will also require function to create polygon. polySides = number of sides in polygon
pointLatArr = Lat of point in in polygon array
pointLngArr = Lng of point in in polygon array
dat.lat = Lat from Haversine results
dat.lng = Lng from Haversine results
if (pointInPolygonpolySides,pointLatArr,pointLngArr,dat.lat,dat.lng)){
var latlng = new google.maps.LatLng(dat.lat,dat.lng);
addMarker(latlng,dat.name);
bounds.extend(latlng);
}
function pointInPolygon(polySides,polyX,polyY,x,y) {
var j = polySides-1 ;
oddNodes = 0;
for (i=0; i<polySides; i++) {
if (polyY[i]<y && polyY[j]>=y || polyY[j]<y && polyY[i]>=y) {
if (polyX[i]+(y-polyY[i])/(polyY[j]-polyY[i])*(polyX[j]-polyX[i])<x) {
oddNodes=!oddNodes;
}
}
j=i; }
return oddNodes;
}
function drawSegment(start,end,radius) {
var d2r = Math.PI / 180;
pointLatArr = new Array();
pointLngArr = new Array();
polyLatLngs = new Array(); // latLngs of polygon
var polyLat = (radius /3963.189) / d2r; // miles
var polyLng = polyLat / Math.cos(center.lat() * d2r);
var centerLatLng = new google.maps.LatLng(center.lat(),center.lng());//Center to start
pointLatArr.push(center.lat());
pointLngArr.push(center.lng());
polyLatLngs.push(centerLatLng);
bounds.extend(centerLatLng);
// Create polygon points (extra point to close polygon)
for (var i = start; i < end; i++) {
// Convert degrees to radians
var theta = i * d2r;
var pointLat = center.lat() + (polyLat * Math.sin(theta));
var pointLng = center.lng() + (polyLng * Math.cos(theta));
var pointLatLng = new google.maps.LatLng(
parseFloat(pointLat), parseFloat(pointLng));
polyLatLngs.push(pointLatLng);
pointLatArr.push(pointLat);
pointLngArr.push(pointLng);
bounds.extend(pointLatLng);
}
var centerLatLng = new google.maps.LatLng(center.lat(),center.lng());//End to center
polyLatLngs.push(centerLatLng);
pointLatArr.push(center.lat());
pointLngArr.push(center.lng());
polySides = polyLatLngs.length;
|
Creating half circle buttons with inward shadow
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I think its not working they way you want it to because when you rotate an object the CSS properties are still applied as if the object was not rotated. So if you make the half circle without the rotating it (which makes more sense to do it this way) i think the effect works better. Here's what I used. .arrow {
background: #efeeee;
height: 45px;
position: relative;
width: 40px;
margin: 50px;
border-radius: 0 90px 90px 0;
box-shadow: inset 4px 0px 6px 0px rgba(0,0,0,.4);
}
|
Dectecting whether a Circle intersects with a Rectangle on its top half or bottom half in LibGDX
Tag : java , By : Thomas Plunkett
Date : March 29 2020, 07:55 AM
wish of those help Keep a reusable extra rectangle instance: private final Rectangle tmp = new Rectangle(); if(Intersector.overlaps(circle, rectangle)){
tmp.set(rectangle.x, rectangle.y + rectangle.height/2, rectangle.width, rectangle.height/2);
if (Intersector.overlaps(circle, tmp){
//top half (or both top and bottom) hit
} else {
//bottom half hit
}
}
|